tieum
3rd April 2009 15:53 UTC
Variable does not expand correctly in File
Hello,
I try the following code
Var MyVar
StrCpy MyVar "C:\Path\myfile.txt"
SetOutPath "$INSTDIR"
File "$MyVar"
When I try to compile my installer I get the error message:
File "$MyVar" -> no files found.
Why is this?
If I try
File "C:\Path\myfile.txt"
it works.
Thanks,
Tieum
Comperio
3rd April 2009 16:20 UTC
Variables are used at runtime. File is a compile-time command, so you can't use variables to define the file name.
You muse either use a 'real' name (File "C:\Path\myfile.txt") or you can use a symbol, like:
!define myFile "C:\path\mayfile.txt"
File ${myFile}
But, you can use variables to specify the output, such as:
File "/oname=$myFile" "C:\myfile.txt"
tieum
3rd April 2009 18:03 UTC
The problem is !define is not "variable." I have documentation in several languages and need to be able to change the path where the documentation is taken from depending on the language on the fly. How can I achieve that?
Update just did it with !define and !undef. Thanks for the help.
Comperio
3rd April 2009 18:36 UTC
I was just going to mention that if you wanted to control what gets installed, then here's a way that should work:
!include LogicLib.nsh
#...
Section
${Switch} $LANGUAGE
${Case} ${LANG_ENGLISH}
File "C:\English.txt"
${Break}
${Case} ${LANG_FRENCH}
File "C:\French.txt"
${Break}
${EndSwitch}
SectionEnd
But, if you instead wanted to build an separate installation for each language, then you could probably use !ifdef blocks for each language. Example:
!ifdef UseEnglish
; code for adding English files
!endif
edit You might also have a look at languages.nsi included in your nsis examples folder for more ideas.