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

Got a problem you cannot solve? Try here.
Post Reply
jsmith
Posts: 178
Joined: Tue Nov 04, 2008 10:47 am

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

Post 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?
Tinus
Posts: 209
Joined: Tue Jun 20, 2006 8:42 am
Location: Germany

Post by Tinus »

This command requires a persistent variable!

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

AxoNet Software GmbH
http://www.axonet.de/products/other-pro ... stallaware
jsmith
Posts: 178
Joined: Tue Nov 04, 2008 10:47 am

Post 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.
Post Reply