Break On
$_ = SetOption('NoVarsInStrings', 'On')
; This is the defined user info - more likely @USERID or %USERNAME%
; It represents a variable name defined in an external INI file that
; should be substituted with actual data
$SpecUser = @USERID
; This is part of the data read from the INI file - I'm too lazy to
; deal with this extra code - yours is working fine..
$IniData = 'home$\$$SpecUser\subfolder' ; example with embedded Variable
;$IniData = 'home$\$$SpecUser' ; example with trailing Variable
;$IniData = 'home$\fixedpath' ; example with no Variable
; THIS IS PSEUDO-CODE - no error checking or optimization has been done!!!
'IniData contains: ' $IniData ? ; just for development / debugging
; Check to see if the INI data requires a variable lookup / replacement
If InStr($IniData, '$$') ; have replacement varname!
; define part 1 of the path
$Part1 = Left($IniData, InStr($IniData, '$$') - 1)
'Part1 contains: ' $Part1 ? ; just for development / debugging
; define a working var containing the rest of the data
$Work = SubStr($IniData, InStr($IniData, '$$') + 2)
'Work contains: ' $Work ? ; just for development / debugging
; WORK contains the variable name and any extra data..
; determine the variable name part
; This string contains all of the characters that define the end of a variable name
; THIS list is not complete
$VarTerms = Chr(9) + Chr(36) + " .,$<>():;'\|/+=" ; list of most variable termination chars
; Loop until all characters have been evaluated
While Len($Work) > 0
$C = Left($Work, 1) ; take the first/next character
If Not InStr($VarTerms, $C) ; don't have a var termination char, so
$VarName = $VarName + $C ; add the char to the varname variable
$Work = SubStr($Work, 2) ; trim the work string
Else
$Part2 = $Work $Work = '' ; we've terminated, so assign the rest to Part2
EndIf ; and clear WORK to end the loop
Loop
'Varname contains: ' $VarName ? ; just for development / debugging
$VarName = Chr(36) + $VarName ; add the "$"
'Varname contains: ' $VarName ? ; just for development / debugging
'Part2 contains: ' $Part2 ? ; just for development / debugging
$So = SetOption('NoVarsInStrings', 'Off')
$ = Execute('$Value = $VarName') ; push the extracted variable data into $Value
$ = SetOption('NoVarsInStrings', $So)
$Path = $Part1 + $Value + $Part2 ; build the complete path
Else
$Path = $IniData ; don't make any changes if no $$ was found
EndIf
'Path=' $Path ?