The problem appears to be with your “string last” command. Unless it is merely a typo, you called it with too many args, resulting in an incorrect value. See the example below:
set a “Thomas Gregory Rioux”
echo $a
Thomas Gregory Rioux
set Pos2 [string last ” ” $a 9]
echo $Pos2
6
set Pos21 [string last ” ” $a]
echo $Pos21
14
Try correcting your “string last” command and you should get the correct results. Let me know if this helps.
Search string2 for a sequence of characters that exactly match the characters in string1. If found, return the index of the first character in the last such match within string2. If there is no match, then return -1. If lastIndex is specified (in any of the forms accepted by the index method), then only the characters in string2 at or before the specified lastIndex will be considered by the search. For example,
I think the problem might be that in your string replace, you are just executing the command, you are not setting the value of OBX5 to the result of executing the string replace command. See the following: