如何在 NSIS 中使用 If Else 比较两个变量?
How to compare two variables using If Else in NSIS?
Var first
Var second
Section
Strcpy $first "1.0"
Strcpy $Second "2.1"
${If} $second > $first
MessageBox MB_OK "Grater"
${Else}
MessageBox MB_OK "Smaller"
${EndIf}
SectionEnd
我写了上面的代码,但它显示的结果更小。以及如何将来自文本文件的整数或双精度值与预定义的双精度或整数值进行比较?
使用LogicLib,你可以像这样比较两个整数:
Var first
Var second
Section
StrCpy $first 1
StrCpy $Second 2
${If} $second > $first
MessageBox MB_OK "Grater"
${Else}
MessageBox MB_OK "Smaller"
${EndIf}
SectionEnd
大写 C StrCpy
。还可以尝试从数字中删除引号 ("
) 以使其成为整数。
另一种方式是这样的:
Push $first
Push $Second
StrCpy $first 8
StrCpy $Second 2
IntCmp $first $Second Equal Val1Less Val1More
Equal:
DetailPrint "$first = $Second"
Goto End
Val1Less:
DetailPrint "$first < $Second"
Goto End
Val1More:
DetailPrint "$first > $Second"
Goto End
End:
Pop $Second
Pop $first
NSIS 在基本指令中不支持浮点数,您需要使用默认安装的 Math plugin...
Var first
Var second
Section
Strcpy $first "1.0"
Strcpy $Second "2.1"
${If} $second > $first
MessageBox MB_OK "Grater"
${Else}
MessageBox MB_OK "Smaller"
${EndIf}
SectionEnd
我写了上面的代码,但它显示的结果更小。以及如何将来自文本文件的整数或双精度值与预定义的双精度或整数值进行比较?
使用LogicLib,你可以像这样比较两个整数:
Var first
Var second
Section
StrCpy $first 1
StrCpy $Second 2
${If} $second > $first
MessageBox MB_OK "Grater"
${Else}
MessageBox MB_OK "Smaller"
${EndIf}
SectionEnd
大写 C StrCpy
。还可以尝试从数字中删除引号 ("
) 以使其成为整数。
另一种方式是这样的:
Push $first
Push $Second
StrCpy $first 8
StrCpy $Second 2
IntCmp $first $Second Equal Val1Less Val1More
Equal:
DetailPrint "$first = $Second"
Goto End
Val1Less:
DetailPrint "$first < $Second"
Goto End
Val1More:
DetailPrint "$first > $Second"
Goto End
End:
Pop $Second
Pop $first
NSIS 在基本指令中不支持浮点数,您需要使用默认安装的 Math plugin...