RE: The infamous LIST again!
cfset cfList = REReplaceNoCase( cfList, ,[[:space:]]*,,NO VALUE STRING,, ALL ) / That should do the trick _ From: Chunshen (Don) Li [mailto:[EMAIL PROTECTED] Sent: 30 June 2004 15:27 To: CF-Talk Subject: The infamous LIST again! SET LIST VALUE: cfset cfList = a,b,,d cfloop index=e list=#cfList# cfoutput #e# /cfoutput /cfloop Three out of the above FOUR list elements would be displayed. No, my application requires more complexity than the above example.The point is, I need a NO VALUE STRING for the third element even if it's EMPTY instead of conveniently ignoring it.An attempt to convert the list to an Array, cfset cfList = a,b,,d cfset anArray4List = ListToArray(cfList) cfset cnt = 0 for argument sake, use plain 4 items here cfloop index=e from=1 to=4 cfset cnt = cnt + 1 cfoutput #anArray4List[cnt]# /cfoutput /cfloop Failed to achieve what is intended.It seems that the ListToArray function converts the 3 elements to an array. What's your way to circumvent this problem? TIA. _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: The infamous LIST again!
Why not do a Replace function on the list prior to outputting it. Replace all the blanks with NO VALUE STRING then problem solved. -Original Message- From: Chunshen Li [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 10:27 AM To: CF-Talk Subject: The infamous LIST again! SET LIST VALUE: cfset cfList = a,b,,d cfloop index=e list=#cfList# cfoutput #e# /cfoutput /cfloop Three out of the above FOUR list elements would be displayed. No, my application requires more complexity than the above example.The point is, I need a NO VALUE STRING for the third element even if it's EMPTY instead of conveniently ignoring it.An attempt to convert the list to an Array, cfset cfList = a,b,,d cfset anArray4List = ListToArray(cfList) cfset cnt = 0 for argument sake, use plain 4 items here cfloop index=e from=1 to=4 cfset cnt = cnt + 1 cfoutput #anArray4List[cnt]# /cfoutput /cfloop Failed to achieve what is intended.It seems that the ListToArray function converts the 3 elements to an array. What's your way to circumvent this problem? TIA. _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: The infamous LIST again!
As you've noticed, ColdFusion list processing ignores empty elements. Before processing the list, replace all of the empty elements with a place holder along the lines of: CFSET theList = Replace(theList, ,,, ,[empty],, ALL) and then, when looping over the list, check for a value of [empty] and replace it with an actual empty string. Note that the above code only replaces empty list elements that are in the middle of the list.It does not catch empty elements at the very beginning or end of the list. -- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ -Original Message- From: Chunshen (Don) Li [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 10:27 AM To: CF-Talk Subject: The infamous LIST again! SET LIST VALUE: cfset cfList = a,b,,d cfloop index=e list=#cfList# cfoutput #e# /cfoutput /cfloop Three out of the above FOUR list elements would be displayed. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: The infamous LIST again!
What's your way to circumvent this problem? 1º CFSET cfList= replace (cfList , ,,, , all) 2º when working on a list element, trim() it to get back an empty string. This will work unless you need to distinguish between one space and an empty element. If it is tehe case, use any special character to replace empty elements. -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: The infamous LIST again!
Try Listfix from cflib: http://www.cflib.org/udf.cfm?ID=507 [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: The infamous LIST again!
The only work around for this that I know is: (I didn't check for errors but this should be close) cfset cfList = a,b,,d cfset cfList = Replace(cfList, ,,, , ,,All) cfif left(cfList,1) EQ , cfset cfList = #cfList# /cfif cfif right(cfList,1) EQ , cfset cfList = #cfList# /cfif cfloop index=e list=#cfList# cfoutput cfif len(trim(e))#e#cfelseEmpty Element/cfif /cfoutput /cfloop HTH, Duane _ From: Chunshen (Don) Li [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 10:27 AM To: CF-Talk Subject: The infamous LIST again! SET LIST VALUE: cfset cfList = a,b,,d cfloop index=e list=#cfList# cfoutput #e# /cfoutput /cfloop Three out of the above FOUR list elements would be displayed. No, my application requires more complexity than the above example.The point is, I need a NO VALUE STRING for the third element even if it's EMPTY instead of conveniently ignoring it.An attempt to convert the list to an Array, cfset cfList = a,b,,d cfset anArray4List = ListToArray(cfList) cfset cnt = 0 for argument sake, use plain 4 items here cfloop index=e from=1 to=4 cfset cnt = cnt + 1 cfoutput #anArray4List[cnt]# /cfoutput /cfloop Failed to achieve what is intended.It seems that the ListToArray function converts the 3 elements to an array. What's your way to circumvent this problem? TIA. _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: The infamous LIST again!
Use cfset cflist = replace(cfList,',,',',$$,','ALL') to replace two comas next to each other with ,$$, or any other recognisable pattern that will not occur in real situations (,NULL, for example).This will change your list into a,b,$$,d And you can then process the replaced string later in your code depending on what you are doing with the list. -- Jay -Original Message- From: Chunshen (Don) Li [mailto:[EMAIL PROTECTED] Sent: 30 June 2004 15:27 To: CF-Talk Subject: The infamous LIST again! SET LIST VALUE: cfset cfList = a,b,,d cfloop index=e list=#cfList# cfoutput #e# /cfoutput /cfloop Three out of the above FOUR list elements would be displayed. No, my application requires more complexity than the above example.The point is, I need a NO VALUE STRING for the third element even if it's EMPTY instead of conveniently ignoring it.An attempt to convert the list to an Array, cfset cfList = a,b,,d cfset anArray4List = ListToArray(cfList) cfset cnt = 0 for argument sake, use plain 4 items here cfloop index=e from=1 to=4 cfset cnt = cnt + 1 cfoutput #anArray4List[cnt]# /cfoutput /cfloop Failed to achieve what is intended.It seems that the ListToArray function converts the 3 elements to an array. What's your way to circumvent this problem? TIA. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: The infamous LIST again!
use some value to represent nothing, like MNDSJDHSIUDGWI and then in your loop, write a conditional so that if e = MNDSJDHSIUDGWI, then output nothing. hehe - Original Message - From: Chunshen Li (Don) To: CF-Talk Sent: Wednesday, June 30, 2004 9:26 AM Subject: The infamous LIST again! SET LIST VALUE: cfset cfList = a,b,,d cfloop index=e list=#cfList# cfoutput #e# /cfoutput /cfloop Three out of the above FOUR list elements would be displayed. No, my application requires more complexity than the above example.The point is, I need a NO VALUE STRING for the third element even if it's EMPTY instead of conveniently ignoring it.An attempt to convert the list to an Array, cfset cfList = a,b,,d cfset anArray4List = ListToArray(cfList) cfset cnt = 0 for argument sake, use plain 4 items here cfloop index=e from=1 to=4 cfset cnt = cnt + 1 cfoutput #anArray4List[cnt]# /cfoutput /cfloop Failed to achieve what is intended.It seems that the ListToArray function converts the 3 elements to an array. What's your way to circumvent this problem? TIA. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: The infamous LIST again!
http://www.cflib.org/udf.cfm?ID=507 -Original Message- From: Chunshen (Don) Li [mailto:[EMAIL PROTECTED] Sent: woensdag 30 juni 2004 16:27 To: CF-Talk Subject: The infamous LIST again! SET LIST VALUE: cfset cfList = a,b,,d cfloop index=e list=#cfList# cfoutput #e# /cfoutput /cfloop Three out of the above FOUR list elements would be displayed. No, my application requires more complexity than the above example.The point is, I need a NO VALUE STRING for the third element even if it's EMPTY instead of conveniently ignoring it.An attempt to convert the list to an Array, cfset cfList = a,b,,d cfset anArray4List = ListToArray(cfList) cfset cnt = 0 for argument sake, use plain 4 items here cfloop index=e from=1 to=4 cfset cnt = cnt + 1 cfoutput #anArray4List[cnt]# /cfoutput /cfloop Failed to achieve what is intended.It seems that the ListToArray function converts the 3 elements to an array. What's your way to circumvent this problem? TIA. [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: The infamous LIST again!
What's your way to circumvent this problem? If you're using MX, you can be a bit sneaky: because the list is an instance of java.lang.String, you can use the methods of that class on it, one of which is the split() method.This method will split a string into an array on a given delimiter (which can be multi-character) and also includes empty values: !--- normal, space delimited string --- cfset myString = this is my space delimited string cfdump var=#myString.split( )# !--- string with multi-char delimiter --- cfset myString= thisCDisCDmyCDotherCDdelimitedCDstring cfdump var=#myString.split(CD)# !--- comma delimited, with empty items --- cfset myString= this,is,a,,comma,,,delimited,,string cfdump var=#myString.split(,)# HTH, Tim. -- --- RAWNET LTD - Internet, New Media and ebusiness Gurus. WE'VE MOVED - for our new address, please visit our website at http://www.rawnet.com/ or call us any time on 0800 294 24 24. --- This message may contain information which is legally privileged and/or confidential.If you are not the intended recipient, you are hereby notified that any unauthorised disclosure, copying, distribution or use of this information is strictly prohibited. Such notification notwithstanding, any comments, opinions, information or conclusions expressed in this message are those of the originator, not of rawnet limited, unless otherwise explicitly and independently indicated by an authorised representative of rawnet limited. --- [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: The infamous LIST again!
Thanks for the REG EXP solution, it seems more elegant than another one that I came up with. cfset cfList = REReplaceNoCase( cfList, ,[[:space:]]*,,NO VALUE STRING,, ALL ) / That should do the trick _ From: Chunshen (Don) Li [mailto:[EMAIL PROTECTED] Sent: 30 June 2004 15:27 To: CF-Talk Subject: The infamous LIST again! SET LIST VALUE: cfset cfList = a,b,,d cfloop index=e list=#cfList# cfoutput #e# /cfoutput /cfloop Three out of the above FOUR list elements would be displayed. No, my application requires more complexity than the above example.The point is, I need a NO VALUE STRING for the third element even if it's EMPTY instead of conveniently ignoring it.An attempt to convert the list to an Array, cfset cfList = a,b,,d cfset anArray4List = ListToArray(cfList) cfset cnt = 0 for argument sake, use plain 4 items here cfloop index=e from=1 to=4 cfset cnt = cnt + 1 cfoutput #anArray4List[cnt]# /cfoutput /cfloop Failed to achieve what is intended.It seems that the ListToArray function converts the 3 elements to an array. What's your way to circumvent this problem? TIA. _ [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: The infamous LIST again!
Oo How did you determine that you could use Java methods within CF syntax? Can you do a join to get the array back to a list? TIA Dick On Jun 30, 2004, at 7:38 AM, Tim Blair wrote: What's your way to circumvent this problem? If you're using MX, you can be a bit sneaky: because the list is an instance of java.lang.String, you can use the methods of that class on it, one of which is the split() method. This method will split a string into an array on a given delimiter (which can be multi-character) and also includes empty values: !--- normal, space delimited string --- cfset myString = this is my space delimited string cfdump var=#myString.split( )# !--- string with multi-char delimiter --- cfset myString= thisCDisCDmyCDotherCDdelimitedCDstring cfdump var=#myString.split(CD)# !--- comma delimited, with empty items --- cfset myString= this,is,a,,comma,,,delimited,,string cfdump var=#myString.split(,)# HTH, Tim. -- --- RAWNET LTD - Internet, New Media and ebusiness Gurus. WE'VE MOVED - for our new address, please visit our website at http://www.rawnet.com/ or call us any time on 0800 294 24 24. --- This message may contain information which is legally privileged and/or confidential. If you are not the intended recipient, you are hereby notified that any unauthorised disclosure, copying, distribution or use of this information is strictly prohibited. Such notification notwithstanding, any comments, opinions, information or conclusions expressed in this message are those of the originator, not of rawnet limited, unless otherwise explicitly and independently indicated by an authorised representative of rawnet limited. --- [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
RE: The infamous LIST again!
How did you determine that you could use Java methods within CF syntax? There are numerous examples of doing that in MX.Another favourite of mine is when looping through a query, you can use myQuery.last() to check if the item you're on is the last record rather than setting an external counter etc. For example, if I want to output a query as a list (yes, before anyone says, I know I can use valuelist() - it's just an example!): !--- before java cleverness --- cfset myCounter = 0 cfloop query=myQuery cfset myCounter = myCounter + 1 cfoutput#myQuery.fieldname#cfif myCounter LT myQuery.currentrow, /cfif/cfoutput /cfloop !--- after java cleverness --- cfloop query=myQuery cfoutput#myQuery.fieldname#cfif NOT myQuery.last(), /cfif/cfoutput /cfloop Can you do a join to get the array back to a list? You can just use the normal CF arraytolist() function to do that - note that doing this will *include* empty array cells, so you can end up with a list (string) that looks like: 1,2,3,,4,,,5,6 Tim. -- --- RAWNET LTD - Internet, New Media and ebusiness Gurus. WE'VE MOVED - for our new address, please visit our website at http://www.rawnet.com/ or call us any time on 0800 294 24 24. --- This message may contain information which is legally privileged and/or confidential.If you are not the intended recipient, you are hereby notified that any unauthorised disclosure, copying, distribution or use of this information is strictly prohibited. Such notification notwithstanding, any comments, opinions, information or conclusions expressed in this message are those of the originator, not of rawnet limited, unless otherwise explicitly and independently indicated by an authorised representative of rawnet limited. --- [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]
Re: The infamous LIST again!
Just want to thank everyone for responding.As I indicated, problem resolved soon after my posting, and also as I said, Alistair Davidson's solution seems an elegant way to fix CF List function deficiency, did not have a chance to check cflib, thought it may be along similar line, so does Adkins, Randy, others maybe, ... SET LIST VALUE: ... [Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]