PDA

View Full Version : Append strings issue



timbojones
08-10-2006, 07:40 PM
I have the following code in my script:

If %USER% Not Equals "" Then
Set Variable %ARGS% to "-username %USER%"
End
If %PASSWORD% Not Equals "" Then
Set Variable %ARGS% to " -password %PASSWORD%"
End

The second Set Variable has the "Append to Existing Value" box checked. Note the space at the beginning of the string. If %USER% and %PASSWORD% are both defined, then at the end of this block, %ARGS% = "-username foo-password bar". The space has been stripped out. The same thing happens if I put the space at the end of the first Set Variable command, or if I append a space in its own Set Variable command.

How can I fix this?

timbojones
08-10-2006, 07:50 PM
I have worked around this issue by assigning to %USERARG% and %PASSWORDARG% and referring to both instead of the single %ARGS%. But this feels very hacky. I don't think you should trim spaces when assigning strings to variables.