flovo
27th January 2004 08:51 UTC
switch case construct
Hello !
I want to realise a switch-case equivalent.
For example while looping I read a variable from an ini file
ReadIniStr $LABEL .....
Each time $LABEL is differnt depending on my loop variable(counter)
Then I want to go to that label.
But a
goto $LABEL
does not make it.
How can I realise this ? What did I miss ?
thanks in advance
flovo
Vytautas
27th January 2004 10:10 UTC
Have you checked out the 'LogicLib.nsh' included in NSIS. I think that it has a case function.
Vytautas
MoNKi
27th January 2004 12:54 UTC
Try with something like this
#switch start
>label_case_1:
>StrCmp $LABEL "1" +1 label_case_2
>#code for "1" here
>goto label_endswitch
label_case_2:
>StrCmp $LABEL "2" +1 label_case_3
>#code for "2" here
>goto label_endswitch
>...
...
>label_case_N:
>StrCmp $LABEL "N" +1 label_default
>#code for "N" here
>goto label_endswitch
label_default:
>#default code here
>label_endswitch:
>#switch end
You only need to change the label's names if you want.
flovo
27th January 2004 13:54 UTC
Thanks for LogicLib.nsh ! That is exactly what I need ! What a pity that it is hide in the example dir !