如何在NSIS中进行复合字符串比较?
基本上类似于:if ( str1 == "" || str2 == "" ) ...
strcpy $1 "c:\foo"
strcpy $2 "d:\bar"
${if} strcmp $1 ""
${orif} strcmp $2 ""
MessageBox MB_OK "one or both are empty"
${else}
messagebox mb_ok "both are not"
${endif}
SectionEnd
答案 0 :(得分:2)
StrCmp
是NSIS字符串比较核心的低级指令,但在使用LogicLib时,您必须使用正确的运算符:==
,!=
,S==
或S!=
(所有这些都列在LogicLib.nsh的顶部,不区分大小写的运算符在内部使用StrCmp
)
!include LogicLib.nsh
Section
StrCpy $1 "c:\foo"
StrCpy $2 "d:\bar"
${If} $1 == ""
${OrIf} $2 == ""
MessageBox MB_OK "one or both are empty"
${Else}
MessageBox MB_OK "both are not"
${EndIf}
SectionEnd