In NSIS Script Language I get an error when I go access a global variable from within a macro.
Is my variable installDirectory truely global? How can I set the variable installDirectory from within a macro or function(if its possible within a function)?
var installDirectory
!macro IdentifyDir
IfFileExists C:\test\9.00\ Version9 AbortInstall
Version9:
$installDirectory "C:\test\9.00\"
AbortInstall:
Abort
!macroend
Also can a Macro &/or function return a value in NSIS(or shd I just use push/pop)?
!macro IdentifyDir
IfFileExists C:\test\9.00\ Version9 AbortInstall
Version9:
return "C:\test\9.00\"
AbortInstall:
Abort
!macroend
var installDir !insertmacro IdentifyDir # is that valid?
There are two issues :
to assign a variable, you miss one assignment instruction; for a string variable you can use
StrCpy:StrCpy $installDirectory "C:\test\9.00\"as stated in your another question about labels, labels are not subs but only some defined points that can be reached by flow control, thus when jumping to the
Version9label, without another jump the execution will run to theAbortstatement that follows the theAbortInstalllabel. You should either put another label likeend_of_macro:before the the!macroEndstatement and add agotobefore theAbortInstalllabel (beware that that the macro is expanded where you put the!insertMacroso you must choose a unique label name, it is not like for sections or functions) or (more elegant) invert the two labels : in the case of the abort the execution will stop there and in the second case it will continue outside of the macroFor your question concerning the return value, you can use the default registers
$0to$9and$R0to$R9