Reputation: 816
I'm trying to write the script in elegant way. i.e. write a piece of function or macro which will check a string for last character '\' and if found will add it to "sample" else it will add "\sample" and return it.
Anyone with any samples ?
Upvotes: 0
Views: 572
Reputation: 101666
You can get the last character of a string with StrCpy $2 "$0" 1 -1
.
Function PathAppend
Exch $0
Exch
Exch $1
Push $2
StrCpy $2 $1 1 -1
StrCmp $2 "\" +2 +1
StrCpy $0 "\$0"
StrCpy $1 "$1$0"
Pop $2
Exch
Pop $0
Exch $1
FunctionEnd
Section
Push "c:\foo\bar"
Push "baz"
Call PathAppend
Pop $9
DetailPrint $9
SectionEnd
Note that the default directory set by InstallDir
already has special handling if you want to append the application name to the directory.
Upvotes: 1