6

Can a NSIS Function have more than one parameter?

Why wont this code compile? If I cant have more than 1 param for a function what are my other options(disregarding using a macro)?

Compile error:

Function expects 1 parameters, got 4. Usage: Function function_name

Outfile "test.exe"
Caption ""
Name ""

# Compile Error Here: "Function expects 1 parameters, got 4. Usage: Function function_name"
Function MyFunction p1 p2 p3
    DetailPrint "$p1, $p2, $p3"
FunctionEnd

Section
    DetailPrint "Hello World"
SectionEnd
sazr
  • 24,984
  • 66
  • 194
  • 362

1 Answers1

9

You have to pass parameters in registers and/or on the stack:

Function onstack
pop $0
detailprint $0
FunctionEnd

Function reg0
detailprint $0
FunctionEnd

Section
push "Hello"
call onstack
strcpy $0 "World"
call reg0
SectionEnd
Anders
  • 97,548
  • 12
  • 110
  • 164
  • When you invoke a function you're allowed to pass it parameters inline. Does it use the stack or the registry for that? – Ring Apr 17 '15 at 20:09
  • @Ring No you cannot pass them inline. You can do it when using the dll::export plugin syntax but the compiler translates those into a push... – Anders Apr 18 '15 at 00:50
  • I was looking at the source of one of these functions: For most libraries they include a !macro definition that allows users to provide parameters inline. In the case of (explode http://nsis.sourceforge.net/Explode) the parameters are pushed and the return is popped. – Ring Apr 20 '15 at 19:22