Archive: Varibles in File


Varibles in File
  Hi,

Just a quick question are you able to use variables in File.

For example




StrCpy $DISTRIBUTION_CD_LOCATION "G:\generic\bbRad distribution CD\bbRad v1.11 ib0\Enterprise\Program Files\bbRad\"

SetOutPath "
$INSTDIR"
SetOverwrite try
File $DISTRIBUTION_CD_LOCATION"bbRadCLI.exe"
>
Using the above I get the following error:

File: "$DISTRIBUTION_CD_LOCATION"bbRadCLI.exe"" -> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
/oname=outfile one_file_only)
Error in script "C:\Documents and Settings\james\workspace\bbRad installer\setup.nsi" on line
75 -- aborting creation process

Is it that you must specify the whole dir to the file when using File, or have I just done something wrong with the var side of things....

Thanks
James

It is that you can't use variables at compile time, instead try to !define DISTRIBUTION_CD_LOCATION


What just like this,


!define DISTRIBUTION_CD_LOCATION "Path here"


Because if thats correct im still getting the same error :(

!define DISTRIBUTION_CD_LOCATION "D:\My Local Path"
File: "${DISTRIBUTION_CD_LOCATION}\bbRadCLI.exe"


You legend. Thanks a lot :D that works brill


Keeping to a similar topic. Is it possible to use a variable in an unistall part.

For example :


Section Uninstall
Delete "$INSTDIR\config\bbRadGateway$INI_NACS.ini"
SectionEnd


Thanks

Yes but its value won't be magically copied from the installer to the uninstaller. You need to store its value in the registry or an INI file.

If its value does not change then use a !define instead.

-Stu


Originally posted by James4563
You legend. Thanks a lot :D that works brill
The only legend that I know around here is kichik, I'm just a consistent of...

Originally posted by Afrow UK
Yes but its value won't be magically copied from the installer to the uninstaller. You need to store its value in the registry or an INI file.

If its value does not change then use a !define instead.

-Stu
Ok thanks. So if I use !define instead will that mean I can just put it into the uninstaller? Or will I still need to store in the reg or an ini file.

Cheers for the help peeps :D

!define makes a compile time constant. Once your installer is compiled, it's value is sustained in a static form wherever it's used. Variables on the other hand are used if your value needs to change while the installer is being executed by the end user. If your value will never change, then use a constant (define) and not a variable. Once you've created a constant, you can use it anywhere in your script whether it's inside or outside sections and functions.

-Stu


Well the value I want to use is acctually enter by the user in the installation config. So im guessing that I cant used !define.

Is it fairly easy to store the values into the Registry? Or would you recommend storing them in an ini file instead?

James


So if I use !define instead will that mean I can just put it into the uninstaller? Or will I still need to store in the reg or an ini file.
!define is ok while its value is global, hence you can't change it at run time.

The registry is probably your safest bet. Use WriteRegStr and ReadRegStr.

There are pros and cons for using the registry or initialisation files, but most people would rather use the registry simply because you don't need to worry about a particular file on the hard drive.

-Stu


Cheers mate. Ill try it out and see what I can do.

Ill post back if I get anymore problems, which I probably will :D