Skip to content
⌘ NSIS Forum Archive

Pass variables between nsh files

7 posts

clk_it#

Pass variables between nsh files

Hi,
I'm using the same things in all my installers,
so I created a script that is used in my nsi files.

Some code of my Installer.nsi:

*******
!include "Common_Lib.nsh" <<THIS IS MY COMMON FILE
...
!define APP_VERSION "1.17.0.0"
!define APP_TITLE "ArgonWare 3"
...
Var FIREBIRD_FULL_TARGETDIR
Var FIREBIRD_FULL_ODBC_TARGETDIR
Var FIREBIRD_TARGETDIR
...
Function xx
!insertmacro FB_1_5_Installa_Server $FIREBIRD_TARGETDIR $FIREBIRD_FULL_TARGETDIR $ODBC_NAME $DATABASE_FILE
FunctionEnd
Function xxx
!insertmacro CREA_CHIAVI_REGISTRO_INSTALLAZIONE $APP_TITLE $APP_VERSION
FunctionEnd
*******

Some code of my Common_Lib.nsh

*******
!macro FB_1_5_Installa_Server FIREBIRD_TARGETDIR FIREBIRD_FULL_TARGETDIR ODBC_NAME DATABASE_FILE
ExecWait '"$INSTDIR\xxxx.exe" xxx /DIR=\"${FIREBIRD_TARGETDIR}\"'
....
!macroend

!macro CREA_CHIAVI_REGISTRO_INSTALLAZIONE APP_TITLE APP_VERSION
....
WriteRegStr HKLM "SOFTWARE\XXX\${APP_TITLE}" "Install_Dir" "$INSTDIR"
....
!macroend
*******

The first macro (FB_1_5_Installa_Server) works fine,
arguments are passed correctly and all goes ok.
The second macro gives errors on compling:
Warning: unknown variable/constant "APP_TITLE" detected, ignoring (macro:CREA_CHIAVI_REGISTRO_INSTALLAZIONE)

Why this?
What is the difference between the 2 macro?

Thanks for the help
kichik#
That happens because you pass it $APP_TITLE and $APP_VERSION when you call it from your script (Installer.nsi).
clk_it#
Sorry, I don't understand.
I'm using the same system for the 2 macros.

The only difference is that in the nsi,
app_title and app_version are !defined, and not variables

But I'm passing the value as argument, not the variable.

What I must change?

thanks
kichik#
The problem is not in any way related to the NSH file or the macros in it. The problem is that you passed $APP_TITLE instead of ${APP_TITLE} in Installer.nsi.
clk_it#
Ok, It's correct.

Now I have another problem:
if I write:
!insertmacro CREA_CHIAVI_REGISTRO_INSTALLAZIONE ${APP_TITLE} ${APP_VERSION}

The compiler tells me:
macro ... requires 2 parameters, passed 3.

Where is the third parameter?

If I remove the second parameter, compiler tells OK.

??

Thanks.
kichik#
The third parameter is in the defines themselves. You must quote both so the space in the define won't count as another parameter.