Page 1 of 1

Using variables set from the command line

Posted: Tue Jan 06, 2009 5:36 pm
by zims
When reading the documentation about how to set a variable at the command line it looks simple.

But my problem is that I can't use the variable with a If statment, if I do that I get an error while compiling that says that the variable is not defined.

But if I defind it with a set command it will override what my user specified at the command line.

I guess I am missing something, can some one please help me?

Zims

Posted: Tue Jan 06, 2009 5:39 pm
by zims
I found this topic:

http://www.installaware.com/forums/view ... e+variable

Which suggests using:
Set Variable COMMANDLINE to $CMDLINE$
If COMMANDLINE contains (ignore case) MYPARAMETER=
Set MYPARAMETER=$MYPARAMETER$
Else
Set MYPARAMETER=
End


Ok, this might work, but it does not feel logical. There must be a more straigt forward way.

I guess almost all custom variables that you set from the commandline will be used in a if statement.

Zims

Posted: Sun Jan 18, 2009 11:31 pm
by gsRon
have you looked at Compiler Variables? You can set them for the project and then set then from the command line. That way they are always present.

optional command-line parameters

Posted: Fri Jan 30, 2009 2:59 pm
by DaveL
I have found the following to work:

Code: Select all

if Variable CMDLINE not Contains (Ignore Case) MYPARAMETER=
  Set Variable MYPARAMETER to ...
end
It's shorter than previously suggested method... No need for additional $COMMANDLINE$ variable, as $CMDLINE$ is always pre-defined and available for if statements. And no need for the else clause because it is enough to have the single Set command for IA to be aware of the variable even if that line never executes (since the variable is initialized via command-line).

I am using IA 8... YMMV.