Is there any code like switch(case_var)?


actually i just read that 2 hour ago XD but thank you for your help


Gyah :weary:


So for the record, I used *rand in my example as just that, an example to show how the rest of it works. Normally you’d want to tie that method to a choice. Just remember that multi-replace starts at index 1, not 0. And yes, the range was from 1 to 3 because there were 3 branches.


Fully functional version of my example:

*label switch_demo

*temp branch ""
*temp index 0

        *set index 1
    #What is your name?
        *set index 2
        *set index 3

*set branch "@{index label_a|label_b|label_c}"
*gosub {branch}

*goto switch_demo

*label label_a

Hello there!


*label label_b

MY name is test.


*label label_c

I am done talking now.


… However, reevaluating the code now, using the multi-replace and referencing really isn’t useful since you can just *goto directly from the choices instead of setting the index and redirecting from there. Off the top of my head, I can’t think of a scenario where this code would be more useful then direct *goto calls.


hmm ok, but if i want to use the choice again for new file i can’t use

*temp branch
*temp index 0

instead i must write

*create branch
*create index 0 right?


Thank you so much guys


*create branch “”
Iirc unless string variables now can do without