Skip to content
⌘ NSIS Forum Archive

OutFile string doesn't accept variable

10 posts

pospec#

OutFile string doesn't accept variable

Hello again!

The OutFile string doesn't accept variable. But it will accept global name defined with !define.
...
Var MUTACE
!define PRODUCT_VERSION "3.45"
...
OutFile "Output\DopravniDenik${PRODUCT_VERSION}$MUTACESetup.exe"
...
Function .onInit
${If} ${DDVERZE} == "CD"
StrCpy $MUTACE ""
${Else}
StrCpy $MUTACE "SD"
${EndIf}
FunctionEnd
...
The output file is then DopravniDenik3.45$MUTACESetup.exe. Am I doing something wrong?

Edit: I forgot - the Name instruction works fine with $MUTACE
Red Wine#
Here we're again...

OutFile is a compile time instruction hence does not accept variables whom usage takes action at runtime.
Red Wine#
Yep a definition should work fine if it is a valid path/file name defined.

E.g. !define MY_OUTPUT "C:\NSIS Projects\My New Project\Setup.exe"
.....

OutFile "${MY_OUTPUT}"
demiller9#
The variables get their values only when the script executes. '.onInit' won't execute and $MUTACE will not have a value, so you cannot use it in the OUTFILE command.

You can use '!if' preprocessor commands to select '!defines' to execute or skip and modify the name based upon conditions that you detect during the compile.

Don
pospec#
OK, I can use a !defined symbol instead of variable.

I have tried following:
Name "${APP_NAME} ${PRODUCT_VERSION} ${MUTACE}"
OutFile "Output\DopravniDenik${PRODUCT_VERSION}${MUTACE}Setup.exe"
Now I call:
makensis script.nsi /DMUTACE="SD"
Output is still DopravniDenik1.0${MUTACE}.exe. Maybe I don't understand you, but in makensis help is written:
/Ddefine[=value] defines the symbol "define" for the script [to value]
pospec#
I am DUMB! I've red about the sequentional processing before 5 minutes. 😢

Thank you very much!