Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 4th September 2006, 06:02   #1
BSOD2600
Member
 
Join Date: Jan 2006
Location: USA
Posts: 82
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:
code:

${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.
BSOD2600 is offline   Reply With Quote
Old 4th September 2006, 06:26   #2
Instructor
Major Dude
 
Join Date: Jul 2004
Posts: 665
code:
${WordReplace} "$R0" "\" "" "E}" $R1
Instructor is offline   Reply With Quote
Old 4th September 2006, 07:28   #3
BSOD2600
Member
 
Join Date: Jan 2006
Location: USA
Posts: 82
That seems to work great. Knew I must've been missing something simple...
BSOD2600 is offline   Reply With Quote
Old 4th September 2006, 09:45   #4
{_trueparuex^}
Senior Member
 
{_trueparuex^}'s Avatar
 
Join Date: Dec 2005
Location: Glow
Posts: 285
${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

The guy with the ridiculous username. Thou shall call him PaR instead.
Visit My Website
{_trueparuex^} is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump