如何在 NSIS 中使用 If Else 比较两个变量?

Vis*_*til 5 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
Run Code Online (Sandbox Code Playgroud)

我已经编写了上面的代码,但它显示的结果较小。如何将来自文本文件的整数或双精度值与预定义的双精度或整数值进行比较?

Pmp*_*mpr 5

使用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
Run Code Online (Sandbox Code Playgroud)

中大写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
Run Code Online (Sandbox Code Playgroud)