jcagle
25th July 2003 23:37 UTC
Function Parameter Line?
Is it possible to pass parameters on the call line of a function? Or, do you need to fill register variables before the function call then read those in the function? OR...is there a way other than functions that I can use that accepts call line parameters (like macros or something???) Thanks!
Joel
25th July 2003 23:58 UTC
Well...If you mean like this:
Function Hello(fg as number)
...
FunctionEnd
No.
But you have the option to use the
Push and
Pop
Before functions.... mostly like this:
Push $0
Call Hello
Pop $0 ; will give you something.
Go to the
Nsis Web archive... there are more examples like this...
jcagle
26th July 2003 00:14 UTC
Thanks for the advice. And...since you brought it up...what exactly do the Push and Pop do? I've looked at the documentation, but I'm having some trouble trying to figure out what exactly it's doing. Maybe you could provide me with an example to explain?!?!?! Thanks much!
Vytautas
26th July 2003 00:27 UTC
ctlajoie has posted a good description of pop and push and how they work. It can be found here. Hope this help you out.
Vytautas
Afrow UK
26th July 2003 11:28 UTC
Exch is useful as well.
Push will push a string onto the stack, and Pop willtake it off again, whereas Exch will exchange the string on the stack with the Exch variable.
Example:
Push hello
Call MyFunc
Pop $0 ;$0 = h
Function MyFunc
Exch $R0 ;$R0 = hello
Push $R1 ;saves $R1 value
Push $R2 ;saves $R2 value
StrCpy $R1 0
IntOp $R1 $R1 - 1
loop:
StrCpy $R2 $R0 1 $R1
StrCmp $R2 "" error
StrCmp $R2 "h" done loop
error:
StrCpy $R2 error
done:
StrCpy $R0 $R2
Pop $R2 ;returns original $R2 value
Pop $R1 ;returns original $R1 value
Exch $R0 ;outputs $R0 value ($R0 = h)
FunctionEnd
-Stu