Variable substituion in localization variables

Got a problem you cannot solve? Try here.
Post Reply
Christoph Schneegans
Posts: 55
Joined: Tue Jan 09, 2007 12:20 pm

Variable substituion in localization variables

Post by Christoph Schneegans »

Hi!

I am experiencing some strange problems with localization variables that contain variable references again. For example, my translations.German contains the line

Die Installation ist fehlgeschlagen: $LASTERROR$.

that is linked to a localization variable named "FinishMainText5", which is displayed in a dialog if necessary. However, in case of an error, only the text

Die Installation ist fehlgeschlagen: .

is displayed in the dialog although $LASTERROR$ is not empty as a MessageBox call confirms.

I have now changed the line in the translations.German file to

Die Installation ist fehlgeschlagen: $LastErrorLocalized$.

and call

Set Variable LastErrorLocalized to $LASTERROR$

right before the dialog is displayed. This works!

So my assumption is that there's a difference between pre-defined variables and user-defined variables. It seems that pre-defined variables in localization variables are resolved e.g. when the setup starts, while user-defined variables are not resolved until the localization variable is evaluated. Is this correct?
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

No, that kind of a distinction doesn't exist.

What is the timing of your calls like? Once Set Variable (or Set Localization Variable) is called, any existing variable references inside that call are resolved immediately. They are not kept unsubstituted for resolution at a later time.

So since $LASTERROR$='' (empty string) at start of setup, and since that's probably around when you are calling Set Variable, this is what ends up happening.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Christoph Schneegans
Posts: 55
Joined: Tue Jan 09, 2007 12:20 pm

Post by Christoph Schneegans »

translations.German and project.mtx define these localization variables:

Code: Select all

LocVarStatic=Die Installation ist fehlgeschlagen: $LASTERROR$
LocVarDynamic=Die Installation ist fehlgeschlagen: $LastErrorDynamic$
And this is the script:

Code: Select all

Set Localization Variable LocVarStatic to 
Set Localization Variable LocVarDynamic to 
 
Set Variable LASTERROR to foobar
Set Variable LastErrorDynamic to $LASTERROR$
MessageBox: , $LocVarStatic$ // Displays "Die Installation ist fehlgeschlagen:"
MessageBox: , $LocVarDynamic$ // Displays "Die Installation ist fehlgeschlagen: foobar"
 
Set Variable LASTERROR to foobar2
Set Variable LastErrorDynamic to $LASTERROR$ 
MessageBox: , $LocVarStatic$ // Displays "Die Installation ist fehlgeschlagen:"
MessageBox: , $LocVarDynamic$ // Displays "Die Installation ist fehlgeschlagen: foobar2"

Terminate Installation
So the reason why LocVarDynamic is evaluted every time is that the LastErrorDynamic is declared after LocVarDynamic?
MichaelNesmith
Posts: 3452
Joined: Thu Dec 22, 2005 7:17 pm
Contact:

Post by MichaelNesmith »

Exactly. If VARIABLE hasn't been defined as a variable, then $VARIABLE$ is interpreted just as a string literal.
Michael Nesmith
Install[b]Aware[/b]
[i]Home of The Next Generation MSI Installer[/i]
Get your free copy today - http://www.installaware.com/
Post Reply