5
votes

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
1

1 Answers

8
votes

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