Archive: switch case construct


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


Have you checked out the 'LogicLib.nsh' included in NSIS. I think that it has a case function.

Vytautas


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.

Thanks for LogicLib.nsh ! That is exactly what I need ! What a pity that it is hide in the example dir !