Page 1 of 1

'if Variable MYVAR not is Defined' -> Compile Error

Posted: Tue Dec 09, 2008 2:39 pm
by jsmith
If I add to my MSIcode:

Code: Select all

If Variable MYVAR not is Defined
  Set Variable MYVAR to some value
end

then click the compile button, I get a Compile Error: "Variable not defined: MYVAR." Yeah, I know. That's what I was testing for. Is this how this is supposed to work?

Posted: Wed Dec 10, 2008 10:58 am
by Tinus
This command requires a persistent variable!

if Variable MYVAR not is Defined
Set Persistent Variable MYVAR to
end

Posted: Wed Dec 10, 2008 1:55 pm
by jsmith
I see, thanks! I don't want the value to persist, though. What I was trying to do was check if a value was passed in on the command line, and set it to a default value if it wasn't. The solution I found in another thread was to do this:

Code: Select all

if Variable CMDLINE not Contains (Ignore Case) MYVAR=
  Set Variable MYVAR to some value
end
It's not exactly elegant given that I could reference the value of MYVAR if it was passed in on the command line, but it works.