Old 26th November 2007, 21:31   #1
wraithdu
Junior Member
 
Join Date: Sep 2002
Posts: 39
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?
wraithdu is offline   Reply With Quote
Old 26th November 2007, 23:24   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th November 2007, 01:43   #3
wraithdu
Junior Member
 
Join Date: Sep 2002
Posts: 39
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.
wraithdu is offline   Reply With Quote
Old 27th November 2007, 17:59   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 28th November 2007, 05:55   #5
wraithdu
Junior Member
 
Join Date: Sep 2002
Posts: 39
Thanks! My brain just needed a kick in the right direction. Works like a charm now
wraithdu is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump