House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Get the Real list len

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Chad McCue
03/29/2007 03:38 PM

This list below really has 20 entries, but when I do a listlen on it, it returns 19. It doesn't read the NULL value in the second spot highlighted in red. I am reading a file that is generated from an outside system, where the administrator does not want change the way it works. 1346||258806|19520722|F|1|2|1|21|0|20050113|1|2|2|1|2|2|3|3|99111

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Che Vilnonis
03/29/2007 03:45 PM

And your question is? :) You'll need to add "placeholder" values back into your list. See link below. Hope that helps. http://cflib.org/udf.cfm?ID=507 This list below really has 20 entries, but when I do a listlen on it, it returns 19. It doesn't read the NULL value in the second spot highlighted in red. I am reading a file that is generated from an outside system, where the administrator does not want change the way it works. 1346||258806|19520722|F|1|2|1|21|0|20050113|1|2|2|1|2|2|3|3|99111

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Christopher Jordan
03/29/2007 07:31 PM

It's a small world really. Not only did my friend Steven Van Gemert write the first version of ListFix(), but I just used it not five minutes ago! :o) Chad, ListFix() is really your best bet to overcome this design flaw in CF. Chris Che Vilnonis wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Josh Nathanson
03/29/2007 03:48 PM

This is a known issue - I think the workaround is to run a replace on the list before you do listlen - stick a whitespace character in there: Replace(list,"||","| |","all") Then you can replace it back the way it was after the listlen if you need to. -- Josh ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Peter Boughton
03/29/2007 04:47 PM

There are several options: 1) Replace blank items with dummies. <cfset Text = Replace(Text,'||','| |','all')/> <cfset Text = Replace(Text,'||','| |','all')/> (You need to do it twice incase there are ajacant blanks.) 2) Use Java methods to handle it. Not sure what the Java listlen equivalent is, but Text.split('|') will convert to an array with blank items being blank items in the array, then you could do arraylen 3) Count the delimiters and add one: <cfset TheLength = 1+Len(REReplace(Text,'[^|]','','all'))/> Other people can probably suggest other methods, which is best depends on what you want to do (ie: if you /just/ want the length, or if you'll then be manipulating the data afterwards). >This list below really has 20 entries, but when I do a listlen on it, it >returns 19. It doesn't read the NULL value in the second spot >highlighted in red. I am reading a file that is generated from an >outside system, where the administrator does not want change the way it >works. > >1346||258806|19520722|F|1|2|1|21|0|20050113|1|2|2|1|2|2|3|3|99111

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Claude Schneegans
03/29/2007 06:46 PM

>>It doesn't read the NULL value It is a bad flaw in design, from the very begining of CF: it never takes in account empty elements in lists. -- _______________________________________ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: piegeacon@internetique.com) Thanks.


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

April 16, 2014

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30       

Designer, Developer and mobile workflow conference