beez
22nd August 2002 15:41 UTC
how to check for a '\' at the end of a string
I have a problem where a user may enter the path and end the line with a '\' and later on I am concatinating a subdirectory to this path. If they use the file browser, the '\' is not there and I simply concatinate it along with my subdirectory. However, when the user enters the '\' themselves I don't know how to determine if the last character is a slash or not. Hope that makes sense... basically my problem is that if there is already a slash I'm getting 'path\\path'.
Thanks,
beez
kichik
22nd August 2002 16:52 UTC
$INSTDIR always gets its trailing back-slash removed. If you want to remove the trailing back-slash for another variable just copy it into $INSTDIR, $OUTDIR or $EXEDIR and copy it back.
beez
22nd August 2002 17:23 UTC
awesome
Thanks! You Rock! :)
pospec
13th May 2008 12:22 UTC
This crazy workaround doesn't work anymore...
Red Wine
13th May 2008 13:20 UTC
Strcpy $R0 "$PROGRAMFILES\"
Strcpy $R1 "$R0" '1' '-1'
messagebox mb_ok '$$R1 == [$R1]'
Strcmp $R1 "\" 0 +2
Strcpy $R0 "$R0" '-1'
messagebox mb_ok '$$R0 == [$R0]'
pospec
13th May 2008 13:25 UTC
Yes, I use it. Thank you for your time :)
pengyou
14th May 2008 14:44 UTC
This crazy workaround doesn't work anymore...
Which version of NSIS are you using? On my system with NSIS 2.37 it still works (I tried $INSTDIR, $OUTDIR and $EXEDIR)
pospec
15th May 2008 05:34 UTC
2.37. I am sorry, it works. I must made a mistake when testing this "feature".