2
檢查變量是否存在於NSIS中的最佳方法是什麼?NSIS:如何檢查變量是否存在
目前,我做這樣的事情:
${If} $NonExistentVar == $$NonExistentVar
但正如預期的情況下,現有的VAR some_var
有$some_var
值這是不行的,我知道這是罕見的,但,有沒有更好的辦法檢查它?
section non_existent_var
detailprint "non existent: $NonExistentVar"
var /global ExistentVar
detailprint "existent: $ExistentVar"
${If} $NonExistentVar == $$NonExistentVar
detailprint "PASS: NonExistent doesn't exist"
${Else}
detailprint "FAIL: NonExistent exists"
${EndIf}
${If} $ExistentVar == $$ExistentVar
detailprint "FAIL: ExistentVar doesn't exist"
${Else}
detailprint "PASS: ExistentVar exists"
${EndIf}
strcpy $ExistentVar "$$ExistentVar"
${If} $ExistentVar == $$ExistentVar
detailprint "FAIL: ExistentVar doesn't exist"
${Else}
detailprint "PASS: ExistentVar exists"
${EndIf}
SectionEnd
給出:
non existent: $NonExistentVar
existent:
PASS: NonExistent doesn't exist
PASS: ExistentVar exists
FAIL: ExistentVar doesn't exist
Completed