|
|
|
|
#1 |
|
Junior Member
Join Date: Mar 2004
Posts: 29
|
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 |
|
|
|
|
|
#2 |
|
Major Dude
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
|
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" |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Mar 2004
Posts: 29
|
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. Last edited by tieum; 3rd April 2009 at 17:23. |
|
|
|
|
|
#4 |
|
Major Dude
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
|
I was just going to mention that if you wanted to control what gets installed, then here's a way that should work:
code: But, if you instead wanted to build an separate installation for each language, then you could probably use !ifdef blocks for each language. Example: edit You might also have a look at languages.nsi included in your nsis examples folder for more ideas.code: |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Jan 2009
Posts: 23
|
it would be helpful if the FILE instruction error explained that variables cannot be used... I've been banging my head for a couple of hours on this weird fault
|
|
|
|
|
|
#6 |
|
Moderator
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,442
|
Variables only work on the end-users machine, not your machine. "$Whatever" is a valid filename, there is no way for the compiler to guess if you wanted a variable or if that is just the name.
IntOp $PostCount $PostCount + 1 |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|