Remove the last character from the variable - Forum

Forum Navigation
You need to log in to create posts and topics.

Remove the last character from the variable

Hi

How can I delete the last character of a variable like 22394?

 

Thanks

@tilesoft

Does this variable contain the number 22394 or a text string "22394" ?

If it is a string ...

SetVar [gkString] "22394"
StrLen "[gkString]" [gkStringLen]
Math "[gkStringLen]-1" 0 [gkStringLenTrimmed]
StrCopy "[gkString]" 0 [gkStringLenTrimmed] [gkTrimmed]
AlertBox "gkTrimmed" "[gkTrimmed]" ""

If it is a number ...

SetVar [gkNum] 22394

BeginJS
$App.gkString = $App.gkNum.toString();
EndJS

... trim first digit
StrLen "[gkString]" [gkStringLen]
Math "[gkStringLen]-1" 0 [gkStringLenTrimmed]
StrCopy "[gkString]" 0 [gkStringLenTrimmed] [gkTrimmed]
AlertBox "gkTrimmed" "[gkTrimmed]" ""

 

luishp, CDY@44 and 2 other users have reacted to this post.
luishpCDY@44tilesoftjavadrajabihakami

Thank you. It works