Page 1 of 1
Additional 'start' parameter for instr() ?
Posted:
Tue Apr 12, 2016 8:56 am
by Electroguard
I don't know if this would be practical to implement or not, but if instr() could take a 3rd parameter as its (optional ?) 'start' location within the main string it could offer a simple way to parse through the string for multiple occurances of demiliters such as "," and "." (for IP addresses) etc?
Re: Additional 'start' parameter for instr() ?
Posted:
Tue Apr 12, 2016 9:34 am
by cicciocb
Hi,
there is the function 'word()' that can help you for that.
Mike (MMISCOOL) put this function recently for that.
Anyway I think that the start parameter can be done.
I was thinking also a instrrev() like in VB to search from the end.
Re: Additional 'start' parameter for instr() ?
Posted:
Tue Apr 12, 2016 10:12 am
by Electroguard
I don't know VB, but I get the idea.
Hey, rather than mess with instr(), why not create a similar PARSE(string, delimiter, occurance) function that would be almost the same, but the third parameter OCCURANCE could also be a negative number, therefore allowing parsing the string from either direction for the appropriate occurance of the delimiter rather than its relative location?
B.T.W. It might be worth adding a note for right() in the Lang Ref just to explain that the start number is counting from the end and not the beginning - cos that's taken me quite a while to figure out.
Re: Additional 'start' parameter for instr() ?
Posted:
Tue Apr 12, 2016 10:58 am
by Electroguard
I'm glad you pointed out Mikes handy word() function, cos it could greatly simplify some things.
Next time someone is updating the Lang Ref it would probably be worth updating the word() explanation from "Will return the unique id of the chip." to something like "Will return a whole word from its specified position in the string."