I can see a way to bypass this error, but the design seems unintuitive… and inconsistent. Because code doesn’t work that way, this means there must be a failure of my understanding.
The error I’m getting is line 28 of startup: It is illegal to fall in to *else statement; you must *goto or *finish before the end of the indented block.
Code demonstration below. The goodCalc function uses what appears to be a superfluous *goto/*label to evade the error, badCalc does not, longCalc has a thing that determines whether to check
*title Testbed
*author Admin
*create testInt 10
*create testBool true
It is apparent that testInt is
*gosub badCalc
.
It is apparent that testInt is
*gosub goodCalc
.
It is apparent that testInt is
*gosub longCalc
Test complete.
*finish
In the same file, below, but broken apart in the post for visibility:
As dfabulich explains in the linked thread, implicitly ‘falling’ out of a series of *ifs leaves you open to control flow bugs. In other words, it becomes vey easy to miss uncaught edge cases. Forcing you to *goto useless labels is very frustrating but it does force you to think about what you’re doing.
It just seems a bit strange to me that the if/elseif/else statements wouldn’t function as a self-contained unit, instead needing a dedicated escape, especially given that if you use a solo if-then, it creates a conditional insertion before continuing.
(For anyone finding this thread in the future through Google, don’t forget to *create implicit_control_flow true before you attempt to set it, natch)
ChoiceScript makes heavy use of gotos and labels, which is uncommon in most modern high level languages. It’s expected that most people will want to change the text based on an if, and different gotos are a tidier way to achieve this. At the end of the day though, this is just how it is and it isn’t likely to change.