2015-12-02 817 views
0

如何在NSIS中执行复合字符串比较?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 

回答

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 
+0

谢谢哟ü。我知道这是愚蠢的! –