NSIS Function with more than 1 parameters
Asked Answered
I

1

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
Islam answered 14/5, 2012 at 0:17 Comment(0)
W
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
Womanly answered 14/5, 2012 at 1:6 Comment(3)
When you invoke a function you're allowed to pass it parameters inline. Does it use the stack or the registry for that?Barbed
@Barbed 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...Womanly
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 nsis.sourceforge.net/Explode) the parameters are pushed and the return is popped.Barbed

© 2022 - 2024 — McMap. All rights reserved.