Using variables set from the command line

Got a problem you cannot solve? Try here.
Post Reply
zims
Posts: 39
Joined: Mon Nov 24, 2008 11:41 am

Using variables set from the command line

Post 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
zims
Posts: 39
Joined: Mon Nov 24, 2008 11:41 am

Post 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
gsRon
Posts: 26
Joined: Sun Sep 14, 2008 10:21 pm

Post 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.
DaveL
Posts: 8
Joined: Tue Sep 30, 2008 11:35 am

optional command-line parameters

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