|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Get the Real list len
This list below really has 20 entries, but when I do a listlen on it, itChad McCue 03/29/07 03:38 P And your question is? :)Che Vilnonis 03/29/07 03:45 P It's a small world really. Not only did my friend Steven Van GemertChristopher Jordan 03/29/07 07:31 P This is a known issue - I think the workaround is to run a replace on theJosh Nathanson 03/29/07 03:48 P There are several options:Peter Boughton 03/29/07 04:47 P >>It doesn't read the NULL valueClaude Schneegans 03/29/07 06:46 P 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 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 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 ----- 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 ----- 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 >>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.
|
May 25, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||