Page 1 of 1

Problems with variables in evaluation install

Posted: Tue Nov 20, 2007 8:49 am
by LarsS
Hi,
I am using the eval version to try making a install that matches our current one made in Wise.

Problem 1:
I want to grab a parameter from the command line if specified or else use a default value set in the script using the following code:
if variable CMDLINEPARAM1 Is Defined
Set Variable ACTUALPARAM1 = CMDLINEPARAM1
else
Set Variable ACTUALPARAM1 = DefaultValue
end
However when I build I get the error "Variable not defined: CMDLINEPARAM1". Is this a bug or have I misunderstood the purpose of "Is defined"?

Problem 2:
When using the pre defined var GPOPATH I also get the "Variable not defined" error.

Question:
When using a rzCheckBox in the dialog designer is the only way to set the initial value from a script variable to use the "via label capton" workaround? Would have expected it to be possible to just use the variable as input just as for edits....

Best regards,

Lars Sondergaard

Still looking for an answer

Posted: Thu Nov 22, 2007 9:10 am
by LarsS
Any chance of having an answer to this before my eval period expires?

Posted: Thu Nov 22, 2007 2:30 pm
by Alex_Ronquillo
LarsS,

Code: Select all

if variable CMDLINEPARAM1 Is Defined
actually checks whether CMDLINEPARAM1 variable has a value or not, not if it has been defined. You need to define every variable dereference in IA before building your project, otherwise you will get this error.
When using the pre defined var GPOPATH I also get the "Variable not defined" error.
That is really strange, make sure you are writing the right variable. GPOPATH is always defined.
When using a rzCheckBox in the dialog designer is the only way to set the initial value from a script variable to use the "via label capton" workaround? Would have expected it to be possible to just use the variable as input just as for edits....
If in your script, before the dialog with your rzCheckBox, you set the value of the variable you are using in the rzCheckBox to TRUE , its default value will be checked, and if you set it to FALSE it will be unchecked

Posted: Thu Nov 22, 2007 6:15 pm
by LarsS
Thanks for the answer. However I still have the problems:

1. If all variables must be defined with a "Set Variable" how is it then possible to find out IF a variable was specified on the commandline or not? If the user specified a variable on the command line using "Set variable" will clear that value.
Maybe I am asking the wrong way. What I want to do is use the value supplied on the commandline if present and if the commandline does not contain a value then use a value hardcoded in the script.

2. I created a new blank project and onyl added the following lines of script:
if Variable GPOPATH not Equals TesValue
MessageBox: Hello, Yes it works
end

This gives an error message "Variable not defined: GPOPATH".

Thanks for any help.

Best regards

Lars Sondergaard

Posted: Mon Nov 26, 2007 12:56 pm
by Alex_Ronquillo
What I want to do is use the value supplied on the commandline if present and if the commandline does not contain a value then use a value hardcoded in the script.
Do the following:

Code: Select all

if Variable CMDLINE Contains (Ignore Case) CMDLINEPARAM1=
   Comment: Use the value of CMDLINEPARAM1 directly
else
   Set Variable CMDLINEPARAM1 to Default Value
end
I created a new blank project and onyl added the following lines of script:
if Variable GPOPATH not Equals TesValue
MessageBox: Hello, Yes it works
end
This gives an error message "Variable not defined: GPOPATH".
You are right, try the following instead:

Code: Select all

Set Variable GPOPATHVAR to $GPOPATH$
if Variable GPOPATHVAR not Equals TesValue
   MessageBox: Hello, Yes it works
end

Re: Problems with variables in evaluation install

Posted: Sat Jun 12, 2010 7:56 am
by rasmusw
I have the same problem with GPOPATH, it was in 9.0 and is still there in 9.0 R2. - The compiler fails when using "IF GPOPATH".
The workaround works, though.

Re: Problems with variables in evaluation install

Posted: Sat Jun 12, 2010 8:29 am
by MichaelNesmith
If has a new "Is Variable Defined" query now, actually. So you don't need to rely on the workaround and can test directly.

Re: Problems with variables in evaluation install

Posted: Sat Jun 12, 2010 2:14 pm
by rasmusw
The problem is not with the actual check. The problem is that the compiler fails with the message "Variable not defined: GPOPATH" on this line:

Code: Select all

If Variable GPOPATH not Equals NULL
Changing it to

Code: Select all

if Variable GPOPATH is Defined
makes no difference. The compiler still fails.

Changing the code to this works (the workaround suggested by Alex_Ronquillo):

Code: Select all

Set Variable GPOPATHVAR to $GPOPATH$
if Variable GPOPATHVAR not Equals NULL

Re: Problems with variables in evaluation install

Posted: Sat Jun 12, 2010 5:17 pm
by MichaelNesmith
The compiler should not choke on an "Is Variable Defined" query. I was able to reproduce this easily and have escalated it to R&D. Thanks!

Re: Problems with variables in evaluation install

Posted: Fri Jun 25, 2010 7:18 am
by MichaelNesmith
Also, here is a useful codeform:

Code: Select all

 if Variable CMDLINE Contains (Ignore Case) VARTOTEST
   Set Variable VARTOTEST to $VARTOTEST$
 end
This lets you easily sniff custom parameters from the command line and insert them into properly defined variables.