Good afternoon. My apologies for the flurry of questions. This may seem like a rerun but I am working on a process that pulls in lines from a file one at a time. Each string is basically a list of tilde delimited values. Some of these values can vary in length or be NULL. I need to change the value of certain items in that list. I have tried using ListSetAt() to try to do this. I use the syntax below against the line below that. This should be changing the value of position 13 in that string, which is currently 48 to a value of 9. Rather, it is changing the value of what is now 0.3414 in position 16. It appears that it is still not recognizing those NULL values between tildes despite having that "YES" argument at the end. Again, any help would be appreciated.
<cfset row = ListSetAt(row,14,9,"~","YES")>
Unless I'm missing something, the value of 48 is in the 13th position, not 14th, if I count correctly.
^ _ ^
Oh yes sir. Sorry about that. I have made that change above. That should be position 13.
When I run the code
<cfset row="MEPMD01~2POOP519~03092019113800PM~6480081580~~~1224714818389~OK~E~KWH~~000015~48~03092019124500AM~00~0.3414~00~0.3396~00~0.1182~00~0.0552~00~0.069~00~0.0642~~~~~~~~~00~0.0606~00~0.081"> <cfset row = listSetAt(row,13,9,"~","yes")> <cfoutput>#row#</cfoutput>
I get the output: MEPMD01~2POOP519~03092019113800PM~6480081580~~~1224714818389~OK~E~KWH~~000015~9~03092019124500AM~00~0.3414~00~0.3396~00~0.1182~00~0.0552~00~0.069~00~0.0642~~~~~~~~~00~0.0606~00~0.081
So, please mark WolfShade's suggestion as the correct answer.
My apologies for the delayed response sir. That is so weird. I swear that wasn't working last week. I am still working with the option of converting that string to an array and then back. I do think that will be the best option. I'll keep you posted on that and mark that as answered as soon as I have that worked out. Thank you again for your time and effort.
Converting to array and then back again is inefficient. If you're getting the wrong result, then some other factor might be at play.
Just copy-paste the code above.
Once again, my apologies for the delay in getting back. This was exactly what I needed. Thanks once again.