Iterate List of Strings
I'm sure this must be a super simple thing, but I could not figure out how to iterate through a list of strings in NSIS. Any suggestions?
5 posts
supported_versions = ['1.2.1', '1.2.2', '1.3.0', '1.3.1']
for value in [1.2, 1.3]:
if ReadRegistry(<hive>, <key>) in supported_versions:
break
Function StrSplitOne
Exch $0 ; Separator
Exch
Exch $1 ; String
Push $2
Push $3
StrCpy $2 0
loop:
StrCpy $3 $1 1 $2
IntOp $2 $2 + 1
StrCmp $3 "" +3
StrCmp $3 $0 0 loop
IntOp $2 $2 - 1
StrCpy $0 $1 $2
IntOp $2 $2 + 1
StrCpy $1 $1 "" $2
done:
Pop $3
Pop $2
Exch $1 ; Remaining
Exch
Exch $0 ; Item
FunctionEnd
Section
StrCpy $0 "1.2.1|1.2.2|1.3.0|1.3.1"
loop:
StrCmp $0 "" done
Push $0
Push '|'
Call StrSplitOne
Pop $1
StrCmp $1 "" next ; Skip empty
DetailPrint "Item:$1!"
next:
Pop $0
Goto loop
done:
SectionEnd