2015-12-02 24 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

謝謝喲ü。我知道這是愚蠢的! –