在NSIS脚本语言中,当我从宏内访问全局变量时,我得到一个错误。
我的变量installDirectory真的是全局的吗?如何在宏或函数中设置变量installDirectory (如果可以在函数中设置)?
var installDirectory
!macro IdentifyDir
IfFileExists C:\test\9.00\ Version9 AbortInstall
Version9:
$installDirectory "C:\test\9.00\"
AbortInstall:
Abort
!macroend另外,宏&/或函数是否可以在NSIS中返回值(或shd,我只使用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?发布于 2012-05-03 16:44:20
有两个问题:
对于字符串变量,您可以使用StrCpy:
Version9标签时,如果没有另一个跳转,执行将运行到AbortInstall标签后面的Abort语句。您应该在!macroEnd语句之前放置另一个类似end_of_macro:的标签,并在AbortInstall标签之前添加一个goto (请注意,宏会在您放置!insertMacro的位置展开,因此您必须选择一个唯一的标签名称,这与节或函数的名称不同),或者(更优雅地)颠倒这两个标签:在中止的情况下,执行将在此处停止,在第二种情况下,它将在宏之外继续执行
!macro IdentifyDir
IfFileExists C:\temp\9.00 Version9 AbortInstall
AbortInstall:
Abort
Version9:
StrCpy $installDirectory "C:\test\9.00\"
!macroend对于有关返回值的问题,可以使用默认寄存器$0至$9和$R0至$R9
https://stackoverflow.com/questions/10426143
复制相似问题