There was a discussion about quoting strings - I can't find it right now - and I came across something tonight that may merit further discussion...
If I say:
code:
$X = "first"
? "X=$X, Y=$Y" ?
I get "X=First, Y=$Y" - which I would kind of expect, since $Y is undeclared and inside of quotes. However, if I rewrite it as:
code:
$X = "first"
? "X=$X, Y=" + $Y ?
I would expect the interpreter to recognize $Y as an uninitialized variable and output Null, but it outputs "$Y" again.
In this example, it isn't a big deal, but I have a few scripts that I was troubleshooting tonight where I execute a command via the Shell statement. I wanted to optionally write the results to a log file. I tried
code:
If $OPTION = "-l"
$LOG = "2>&1>> C:\TEMP\my.log"
EndIf
$CMD = "%COMSPEC% /c someprog.exe $LOG"
shell $CMD
I expected that if $LOG was undefined, it would be NULL and the command output would appear as expected. If $LOG was defined, it would receive the results via the redirection. However, when $LOG is undefined, the command complains that "$LOG" is an unknown parameter.
Of course, this is easily fixed by first declaring $LOG to be null. Maybe there should be consideration for a defined "print" command that would treat all "$XXX" format strings as vars, initialized or not. ???
Glenn
PS - yes, I know that good coding requires that vars be declared, but that's why I script
_________________________
Actually I
am a Rocket Scientist!