I have run into a couple problems recently with string manipulation. I am storing reasonably large amounts of data in strings where each character can be a value between "0" and "9" and "A" to "F". Dealing with individual characters has been okay, but occasionally I need to handle longer strings and occasionally the fact that those longer strings start with "0" is really really important. This is when the script language's type-less state becomes a real pain. For example:
Code: Select all
[h:s="0"]
S=[r:s]<br>
IndexOf=[r:indexOf("01234",s)]<br>
[h:fData="01234"]
IndexOf=[r:indexOf(fData,s)]<br>
fData=[r:fData]<br>
What results would you expect from this? Unfortunately you get 0 and -1 because fData gets changed from "01234" to 1234
Now when this occurs in the middle of a nest of recursive functions and when the strings rarely start with a "0", this is a royal pain in the stack to debug. I don't really want to stick a "Z" on the end of every string (which solves the problem above). So I was wondering how other people deal with this issue?