Vscode ext giving weird quicktest error

I’ve had this particular file bug free for months (and haven’t touched it) and all of a sudden the quicktest in the vscode extension is giving me an error on it. Is this actually an error?

You should end the *if statements with *else

The program ‘usually’ keeps looking for an *else to finish.

This is ‘wrong’:

*if
*if
*if

This is okay:

*if
*if
*else

The same applies to *if *elseif
The last condition should be true if all the prior ones were false, so there’s no need for an *elseif condition cause the condition should always be true, so you can and should end it with an *else because no matter what, else doesn’t have a condition so it will always check.

There’s a way around changing the flow control or something like that, but personally, I haven’t used it, so I can’t recommend using it.

I’ll give it a shot and just change the elseifs to elses then. The elseif isn’t necessary, I just wanted to be able to see the condition in case I needed a reminder. I’ll just add more comments. Thanks

1 Like

Mind you, you only need to change the last one, all the others *elseif are fine.

I know you don’t see the condition but that’s how it is the logic of coding. If the condition needs to always be true, you don’t need to check for it and just use an *else which means: if all the previous conditions are false, do this.
Otherwise, if all the previous conditions are false and the last one too, that will render an error.

Maybe not the best to use for writing interactive fiction, but that’s something brought from coding we have to adapt to, since here we mix both writing and coding.

I understand. I’m much more of a programmer than a writer. I just don’t understand why it’s suddenly throwing an error after months. It fixed some of the errors. But this one doesn’t make since to me. Shouldn’t *elseif just be treated like another if and skipped over if one is found to be true?

1 Like

Read the error. You’re not *goto or *finish

You need to do that for each condition, else, the program doesn’t know where to go.

Edit: Check all your elseif, you have several to fix there.

Hmm I just didn’t think it read it that way. I may be getting it confused with a different programming language. I’ll go through and fix them.

1 Like

The program essentially reads the code and pauses when finds a *page_break or *choice for user input.

Otherwise keeps going through all the conditions and gotos it finds. If it doesn’t reach a pause or a goto or a finish/ending, then pretty much there is an error.

We can read and pause whenever we want, but the program execution doesn’t. It keeps going until it finishes or needs to wait for the user input.

1 Like

ChoiceScript requires every if/elseif/else or if/else block to include gotos at the end of each possibility. Other programmers have noted the difference with other languages:

As a writer rather than a programmer, I can see what Dan was going for. But if it drives you nuts, turn on Implicit Control Flow. (You can also see Dan’s explanation behind that link for why he wrote CS to require gotos.)

1 Like

I’m adding it right now! Thank you!