检查 NSIS 中是否存在 var 的最佳方法是什么?
目前我做这样的事情:
${If} $NonExistentVar == $$NonExistentVar
但是,如果现有 varsome_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