Skip to content
⌘ NSIS Forum Archive

A macro calling a macro is invalid?

3 posts

nsnb#

A macro calling a macro is invalid?

Being purist that I am, I use the following technique to implement a single function for both install and uninstall sections, without writing it twice:

!macro MACROFUNC un0
Function ${un0}MyFunc
  # NSIS code that works perfectly well.
FunctionEnd
!macroend
!insertmacro MACROFUNC ""
!insertmacro MACROUNFUNC "un." 
Calling MyFunc and un.MyFunc from a script works perfectly, if it is a direct call:
  Push "somestring"
  call MyFunc 
However, when I try to further "macrosize" the above by:
!macro MACRO_INST param
  Push ${param}
  call MyFunc
!macroend 
So that I can call the function in a single line:
MACRO_INST "somestring" 
NSIS compiler fails with an error:
Invalid command: MACRO_INST
What am I doing wrong? What am I missing?

Thanks.
Zinthose#
you need to call the macro properly..
!insertmacro MACRO_INST "somthing" 
To make it easier to read, make a define:
!define MACRO_INST "!insertmacro MACRO_INST"
${MACRO_INST} "somthing" 
nsnb#
OK, the following does work:
!insertmacro MACRO_INST "somestring" 
as documented in the manual.

I forgot the !insertmacro. Sorry for the false alarm.