当前位置: 首页 > 文档资料 > NSIS 用户手册 >

E.4 逻辑函数库

优质
小牛编辑
125浏览
2023-12-01

E.4.1 介绍

包含文件:

!include "LogicLib.nsh"

使用 NSIS 的宏来提供各种逻辑基本语句,不需要预先添加函数。

E.4.2 基本语句

  • If|Unless..{ElseIf|ElseUnless}..[Else]..EndIf|EndUnless
    - 有条件的执行一个语句区块,取决于表达式。
  • AndIf|AndUnless|OrIf|OrUnless
    - 给 If、Unless、ElseIf 和 ElseUnless 增加额外的条件语句。
  • IfThen..|..|
    - 有条件的执行一个内联语句,取决于表达式。
  • IfCmd..||..|
    - 条件的执行一个内联语句,取决于 NSIS 函数提供的真值。
  • Select..{Case[2|3|4|5]}..[CaseElse|Default]..EndSelect
    - 执行多个语句区块之一,取决于表达式的值。
  • Switch..{Case|CaseElse|Default}..EndSwitch
    - 跳转到多个标记之一,取决于表达式的值。
  • Do[While|Until]..{ExitDo|Continue|Break}..Loop[While|Until]
    - 重复一个语句区块直到停止 取决于表达式的值。
  • While..{ExitWhile|Continue|Break}..EndWhile
    - DoWhile..Loop 的别名 (向后兼容)
  • For[Each]..{ExitFor|Continue|Break}..Next
    - 重复语句区块来连续改变变量的值。

E.4.3 表达式

  • 标准 (内建的) 字串判断 (不区分大小写):
    a == b; a != b
  • 另外的不区分大小写的字串判断 (使用 System.dll):
    a S< b; a S>= b; a S> b; a S<= b
    - 需要在 !include LogicLib.nsh 之前 !define LOGICLIB_STRCMP
  • 区分大小写字串判断 (使用 System.dll):
    a S== b; a S!= b
    - 需要在 !include LogicLib.nsh 之前 !define LOGICLIB_STRCMP
  • 标准 (内建的) 有符号整数判断:
    a = b; a <> b; a < b; a >= b; a > b; a <= b
  • 标准 (内建的) 无符号整数判断:
    a U< b; a U>= b; a U> b; a U<= b
  • 64 位整数判断 (使用 System.dll):
    a L= b; a L<> b; a L< b; a L>= b; a L> b; a L<= b
    - 需要在 !include LogicLib.nsh 之前 !define LOGICLIB_INT64CMP
  • 内建的 NSIS 标记判断:
    ${Abort}; ${Errors}; ${RebootFlag}; ${Silent}
  • 内建的 NSIS 其它判断:
    ${FileExists} a
  • 任何有条件的 NSIS 指令判断:
    ${Cmd} a
  • 区段标记判断:
    ${SectionIsSelected} a; ${SectionIsSectionGroup} a;
    ${SectionIsSectionGroupEnd} a; ${SectionIsBold} a;
    ${SectionIsReadOnly} a; ${SectionIsExpanded} a;
    ${SectionIsPartiallySelected} a
    - 需要在 !include LogicLib.nsh 之前 !define LOGICLIB_SECTIONCMP

E.4.4 例子

    ;见 Examples\LogicLib.nsi