Archive: Double variable expansion


Double variable expansion
Is there a way to make NSIS do double variable expansions? I'm trying to set some environment variables that are read from an INI file. The values in the INI file reference variables set in the launcher. For ex the INI has sections like -

[1]
name=TCDrive
value=$MEDIAROOT

The var $MEDIAROOT is derived in the launcher. The name and value are read from the INI into $R0 and $R1, and the System call uses "$R0" and "$R1". What I get is an environment variable like (type set at command prompt) -

TCDrive=$MEDIAROOT

So how can I get NSIS to do the double expansion so I get the correct env var?


You'll have to manually implement that as all of the expansion is done in the compiler at build time and the installer itself doesn't know how to expand them. The installer itself isn't even aware the variables have names.


Do you have any tips on how I should go about doing that? I've got no idea. Also, how is that possible that all expansion is done at compile time? Any of the contstants must be expanded at runtime as they change from system to system and based on the current script directory.

Anyways, I can't figure out how to accomplish what I want. Reading from the INI seems to cause the problem.


You can use the WordReplace function.

The variables aren't actually expanded at compile-time. That was wrong term usage on my end. But they are stripped of their names and assigned a number, so the installer doesn't know of names at all.


Thanks! My brain just needed a kick in the right direction. Works like a charm now :)