Anyway, I know I'm doing some things inefficiently, as all beginnners do, but I have what I think is a simple question and I've not seen the magic header command or custom function/macro that makes this more 'elegant' , but its gotta be out there (?)
I have to evaluate a path from a text control to normalize it for use, in two ways:
1) If the path supplied did not have a trailing slash, append one.
2) In either case, append a subdirectory to the string
So there are two outputs I'm looking for, shown here as $1 and $5, respectively
StrCpy $1 "C:\somepath\" ;from input may or may not have trailing backslash
StrLen $2 $1
IntOp $3 $2 - 1
StrCpy $4 $1 "" $3 ; now i know the last char in $4
${If} $4 != "\"
StrCpy $5 "$1\SubDir\" ;Append Dir (case 2) "C:\somepath\Subdir\"
StrCpy $1 "$1\" ;normalize input (case 1) "C:\somepath\"
${Else}
StrCpy $0 "SubDir\" ;workaround(?) for concat of strings to avoid C:\somepath\\SubDir\
StrCpy $5 "$bkuppath_state$0" ;C:\somepath\Subdir\
This works, but it seems a bit...verbose. And looking ahead i see needing to evaluate this condition a lot.
Is there a better way? Teach me, i am in the throes of NSIS scripting consumption, and i need nourishment.
Thanks in advance for help!