Standard substring functions should be added, i.e.
<string> xSubString <string>, <start>[, <len>]
<string> xStringConcat <string>, <string>, ...
xSubString would be most useful if it would work as follows:
<start> is an index, starting from 1. If positive, it starts from the beginning of the string; if negative, from the end. If zero or off the end of the string, an empty string is returned
<len> is a length. If omitted, the remainder of the string from the starting position is returned. If positive, up to <len> characters are returned from the starting position (fewer if the end of the string is reached first). If negative, it is treated as zero.
Thus, for example, for a string of 'abcde':
xSubString string, 2 returns 'bcde'
xSubString string, 2, 2 returns 'bc'
xSubString string, -3 returns 'cde'
xSubString string, -3, 2 returns 'cd'
Logged In: YES
user_id=178930
Originator: YES
Addendum: if possible, the full applicable set of string functions should be implemented (see, for example, C++ standard strings for possible functions).
Logged In: NO
xStringBuild can do it:
"
%2s skips the first two characters of the string, but inserts the rest.
%.3s inserts only three characters of the string.
%4.5s skips 4 characters, then inserts the next 5 characters of the string.
"
If you want to do it variably, build a string first:
setx pattern to xStringBuild, "%%%d.%ds", start, len ; "%%" adds a single %, %d inserts a number
setx needle to xStringBuild, pattern, haystack
I'm not sure if "0.3s" is equivalent to .3s so you might need more checks:
ifx( start )
setx pattern to xStringBuild, "%%%d.%ds", start, len
else
setx pattern to xStringBuild, "%%.%ds", len
endif
setx substr to xStringBuild, pattern, str