zip_doo_dah
29th April 2003 20:31 UTC
If Else
Hello everyone.
I'm using InstallOptions to gather a parameter from the user and can't quite figure out how to execute an if/else structure. I'm asking the user whether they are using Com1, Com2, or USB and I want to set an INI file parameter to 1, 2, or 5 depending on the response. How might one do this? Thanks for the help.
-Justin
Joost Verburg
29th April 2003 21:29 UTC
Example:
ReadIniStr $R0 "yourfile.ini" "Field 1" "State"
StrCmp $R0 "1" 0 +3
;COM1
WriteIniStr "anotherfile.ini" "Use Port" "COM1"
Goto done
ReadIniStr $R0 "yourfile.ini" "Field 2" "State"
StrCmp $R0 "1" 0 +3
;USB
WriteIniStr "anotherfile.ini" "Use Port" "USB"
Goto done
done:
Afrow UK
30th April 2003 16:16 UTC
The +3 works as a relative jump, ignoring spaces between commands and ignoring comments.
So,
StrCmp $R0 "1" 0 +3
If $R0 is 1 then goto 0 (carry on)
Else (if $R0 is anything else but 1,) then skip the next 2 commands onto the 3rd command.
-Stu
Joost Verburg
30th April 2003 16:24 UTC
It goes to the third command after the jump, so it skips two, not three.
Afrow UK
30th April 2003 18:28 UTC
LOL yes
-Stu
zip_doo_dah
2nd May 2003 20:30 UTC
Thanks! Worked like a charm!
-Justin