Add a string to the list

Hi,

I want to add a string to the list, but right now it add it as an integer.

output:

V9.10,V9.11,V9.20

but what I want is this:

'V9.10','V9.11','V9.20'

<cfset FoundVersionList = "">
<cfif StructKeyExists(Form,'Version') && #form.Version# neq "">
	<cfloop index="vl" list="#form.Version#">
 		<cfif listFind(FoundVersionList,vl) eq 0> 
     		<cfset FoundVersionList = listAppend(FoundVersionList,vl)>
 		</cfif> 
	</cfloop> 
     <cfdump var="#FoundVersionList#">
</cfif>

Open in new window


Thank you,
Lulu
lulu50Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gdemariaCommented:
I would allow your list to remain with just the comma as the delimiter, then when you are ready to print it or write it to a file, or whatever you are going to do with it, then you can just change the delimiter..

   '#listChangeDelim(FoundVersionList,"','")#'

This will change the delimiter from ,   to ','   and then you just need to be sure to have a ' at the beginning and end...
Gurpreet Singh RandhawaCEOCommented:
you can try this:

<cfset foo="V9.10,V9.11,V9.20">
    <cfoutput>#listQualify(foo,"'")#</cfoutput>

Open in new window


works with all coldfusion engines

another code same way

<cfset foo="V9.10,V9.11,V9.20">
    <cfset wrap = listQualify(foo,"'")>
    <cfoutput>#wrap#</cfoutput>

Open in new window


The way @gd told is also correct

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gdemariaCommented:
I like listQualify() as probably a better option - I think it is available in CF 9 and later, not CF 8 if you have that one
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Gurpreet Singh RandhawaCEOCommented:
@gd: listqualify is pretty old,so you will even find in coldfusion version 7 also
lulu50Author Commented:
Couldn't get it to work with
'#listChangeDelim(FoundVersionList,"','")#'

but it did work with this

<cfset foo="V9.10,V9.11,V9.20">
    <cfoutput>#listQualify(foo,"'")#</cfoutput>

Thank you for all your help.

Lulu
lulu50Author Commented:
Thank you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.