簡體   English   中英

NSIS:如何使用前置程序或

[英]NSIS: How to use the preporcessor or

我想要這樣的東西

!if (${Flag} == 5) || (${Flag} == 7)
     ...
!endif

但是我收到錯誤消息!if expects 1-4 parameters, got 7. Usage: !if [!] value [(==,!=,<=,<,>,>=,&&,||) value2] [...] 我試過大括號,但無濟於事。 文檔中提到|| 允許使用。

我也找到了解決方案

!macro test
    ...
!macroend
!if ${Flag} == 5
     !insertmacro test
!else if ${Flag} == 7
     !insertmacro test
!endif

但是此解決方案非常麻煩,然后||導致什么呢?

!if不支持多個表達式,它支持1或3個參數(不計算!前綴)。 || 只是一個布爾表達式( OR ),其中至少一個參數必須計算為true:

!if ${Foo} || ${Bar}
     ...
!endif

多個表達式必須一個一地求值:

!if ${Flag} = 5
     !insertmacro DoSomething
!else if ${Flag} = 7
     !insertmacro DoSomething
!endif

我忘記了引號。 但是,錯誤消息不是很有幫助。

這是解決方案

 !if "${Flag} == 5" || "${Flag} == 7"
     ...
 !endif

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM