BSOD2600
4th September 2006 07:02 UTC
How to remove trailing slash
How would one remove a trailing \ from a variable's last position? If this was C++, I'd just check if the last character was a \ and remove it...
I tried using WordReplace:
${WordReplace} "$R0" "\" "" "E-1" $R1
The problem I'm running into, is that if a variable holds just C:\, then it works fine (spits out
C:). If the variable holds C:\Inetpub\wwwroot, it'll spit out
C:\Inetpubwwwroot.
Instructor
4th September 2006 07:26 UTC
${WordReplace} "$R0" "\" "" "E}" $R1
BSOD2600
4th September 2006 08:28 UTC
That seems to work great. Knew I must've been missing something simple...
{_trueparuex^}
4th September 2006 10:45 UTC
${WordReplace} is pretty heavy solution for this problem. This simple code will do the same thing.
; $R0 = your path
StrCpy $R1 "$R0" "" -1 ; this gets the last char
StrCmp $R1 "\" 0 +2 ; check if last char is '\'
StrCpy $R0 "$R0" -1 ; last char was '\', remove it