Old 5th December 2007, 05:54   #1
vtsaran
Junior Member
 
Join Date: Mar 2003
Location: Arlington, VA, USA
Posts: 25
Question User variables in file paths during file extraction

Hello all,
OK, I searched everywhere but could not find any answers to my question below (perhaps wrong keywords?).
I am trying to have my installer modify file paths during the file extraction based on the user input. Very likely I am doing something wrong because NSIS badly complains at me.
Here is an example:

Say, I would like different files to be extracted depending on the language that the user chooses from a dropdown list. I store their choice in a user variable $MyLang, like so

var $MyLang

In the "install" section, I would like to do this:
IfFileExists "..\SomePath\$MyLang\SomeFile" 0 +3
file "..\SomePath\$MyLang\SomeFile"
goto SomewhereElse
MessageBox MB_OK "No supporting files for your particular language found ,defaulting to English."
file "..\SomePath\SomeFileInEnglish"

It seems that both IFFileExists and File commands ignore my $MyLang variable. In the case of File instruction NSIS complains that "..\SomePath\$MyLang\SomeFile" cannot be found.

Any ideas on how I can solve this problem?
I am suspecting that NSIS doesn't like my variables because they are filled in at runtime, but there has to be some way around this.

Thanks for any help.
Regards,
Vic
vtsaran is offline   Reply With Quote
Old 5th December 2007, 14:53   #2
Fightin_Foo
Junior Member
 
Join Date: Nov 2007
Location: Ohio
Posts: 49
Send a message via AIM to Fightin_Foo
You may be right about NSIS not liking the variables because they are filled at runtime. Have you considered writing a macro or function to extract the files for each language you are supporting? You can still take the input from the user and then put the MyLang variable into a switch or a series of if else if, and then NSIS only extract the files according to the selected language. It may make your installer bigger than you wanted, and there is probably a better solution out there, but it should work.

From there to here,
from here to there,
funny things
are everywhere.

Dr. Seuss
"One Fish Two Fish Red Fish Blue Fish"
Fightin_Foo is offline   Reply With Quote
Old 5th December 2007, 17:45   #3
vtsaran
Junior Member
 
Join Date: Mar 2003
Location: Arlington, VA, USA
Posts: 25
I guess that may work, but seems a bit inefficient

Thanks for your suggestion. I guess, this would my last choice as I wanted all the matching happen automatically. In my installer tree I have folders that are named according to the language abbreviations and it would be easier if the extraction was dependant on one variable rather than on the set of if-else statements. This means that I would not have to modify the installer every time a new language (think folder) is added.
Any more cool ideas out there?
Thanks.
vtsaran is offline   Reply With Quote
Old 6th December 2007, 09:42   #4
Coolblu77
Junior Member
 
Join Date: Nov 2007
Location: Nottingham, UK
Posts: 14
I'm not sure why the IfFileExisits would ignore your variable.

But I was under the impression that File was used to add files in at compile time and then extract them during installation.
So it makes sense that a variable cannot be used here.

How about, adding the extra files you want to distribute along with the installation.exe, not compiled into the exe but in a seperate folder, then use something like:
CopyFiles "$EXEDIR\SomePath\$MyLang\" "$INSTDIR"
(This will copy all the files in the $MyLang directory to the installation directory.)
CopyFiles "$EXEDIR\SomePath\$MyLang\SomeFile" "$INSTDIR"
(or this will only copy one file)
Coolblu77 is offline   Reply With Quote
Old 7th December 2007, 00:49   #5
vtsaran
Junior Member
 
Join Date: Mar 2003
Location: Arlington, VA, USA
Posts: 25
OK thanks, I will give this a thought and a shot!
vtsaran 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