How can I check for a variable not defined ?

Got a problem you cannot solve? Try here.
Post Reply
maurosturaro
Posts: 22
Joined: Tue Mar 14, 2006 6:29 am

How can I check for a variable not defined ?

Post by maurosturaro »

Using a Persistent variable I need to set it to a default value if it is not already initialized from a previous execution.

I've seen from the debugger that a command like
Set Variable SELECT to $MyVariable$
takes the value "$MyVariable$" (the name surrounded by $ sign) if the variable is not defined, so I've try to check if the variable SELECT contain a $ sign.
... but I've got a lot of strange error :
1) Runtime error in insall: cannot open the file "{omiss}\\Temp\\mia13\\.dfm" (note that file name is empty)
2) Runtime error in install: List index out of bouns (25)
depend on how I try to test it.

could you help me ?
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

Interesting case...I don't think testing if a variable has been defined is supported (as confirmed by your test results).

The proper approach is to make sure the persistent variable is always defined on each run of your software. This will be guaranteed if you make sure you define it the very first time setup runs. There is a nice place to do this in your script, the same place that initializes the TARGETDIR and STARTMENU variables to their initial values (these variables are persisted automatically).
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
maurosturaro
Posts: 22
Joined: Tue Mar 14, 2006 6:29 am

Post by maurosturaro »

But with the new #LOADOLDDATA# I don't know if the variable is already defined, by loading of setup data from an older prduct version, or this is a first installation and I must initialize all my variables.

Also I need to modify the initialization of TARGETDIR and STARTMENU variables so it's previous value is not overvritten by default values.
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

That's why LOADOLDDATA is optional ;)
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
maurosturaro
Posts: 22
Joined: Tue Mar 14, 2006 6:29 am

Workaround

Post by maurosturaro »

The following code work.
The parse command is the only way I found to set a variable to a dollar sign, getting the first of a two dollar sign
:idea:

Code: Select all


Comment: load only 1 caracter 
Parse String $$ into Variables DOLLAR and  (Split at position from start)
Set Variable SELECTED to $MYVARIABLE$
if Variable MYVARIABLE Contains $DOLLAR$
  Comment: initialize default value
  Set Persistent Variable MYVARIABLE to INITIALVALUE
end
:!:
Post Reply