Function parameters
Hello!
I have just started to use NSIS for one of my projects. In my installer script I want to use functions and I want to pass parameters to these function. As far as I can see the standard way of doing this is using the stack. If I have a function taking three parameters it will look something like this
Function GetRegValue
Exch $R2 ; 3rd parameter, default
Exch
Exch $R1 ; 2nd parameter, name
Exch
Exch 2
Exch $R0 ; 1st parameter, sub_key
Push $R3 ; Save
ReadRegStr $R3 HKLM $R0 $R1
IfErrors use_default
StrCpy $R2 $R3
Goto end
use_default:
;StrCpy $R0 $R2
end:
Pop $R3 ; Restore
Pop $R0 ; Restore
Pop $R1 ; Restore
Exch $R2 ; Restore and return
FunctionEnd
All the Exch instructions to retrieve the arguments and store the values of the variables we need to use are kind of cryptic to say the least. Is this the best practice when it comes to parameters to functions in NSIS or is there a better way?
Regrads,
Mattias