Can't figure out error with *else

So, I’ve run into something that I’ve been banging my head against for nearly an hour, and I’m not getting anywhere.

When I run Quicktest, it errors out with the message:
QUICKTEST FAILED
Error: ch-three line 658: It is illegal to fall in to an *else statement; you must *goto or *finish before the end of the indented block.

And I get that. Thing is, it looks to me like everything already has a *goto pointing at a valid label. Code chunk follows. Very minor spoilers if you’re following my WIP, and a language warning as well. Joey Sands is a very bad man with a very foul mouth.

*if ((Paulie_dead) and (Joey_shot))
    “I’m gonna start by payin’ you back for this,” he tells you, slightly raising his right arm which is bound in a crude sling.  “Hurts like a motherfucker.”
        
    “Also,” he continues, “there’s the little matter of you blowing Paulie’s fuckin’ brains all over the room.  I can’t let somethin’ like that go.  I got a rep to maintain, after all.”
    *goto Joey_respond

*if ((Paulie_shot) and (Joey_shot))
    “I’m gonna start by payin’ you back for this,” he tells you, slightly raising his right arm which is bound in a crude sling.  “Hurts like a motherfucker.”
        
    He chuckles, then continues, “Yeah, that was some real O-K Corral shit you pulled back there.  You’re just lucky Paulie’s too stupid to know when to die.”
        
    You look over to see the giant in the tan suit standing in the far corner of the small room.  He still wears his too-small jacket, but his shirt has been completely cut away and his torso bandaged where your bullets entered his chest.  He gives you a waggle-fingered wave and grins in your direction.
        
    The thin man continues, “Paulie, he don’t talk much on account of his old man slit his throat when he was nine years old.  Like I said, too stupid to know when to die.”
    *goto Joey_respond

*if (Paulie_burned)
    “I fuckin’ hate you mage types,” he continues.  “Always thinkin’ you’re so fuckin’ high n’ mighty.  Well, ${formal} Magic Fingers, you got your fuckin’ clock cleaned by two guys from the West Sprawl.  Not so goddamn tough now, are you Sparkles?”
        
    He punctuates his monologue by spitting at your feet.  In the far corner of the small room you see the giant in the tan suit glaring at you.  Both of his hands are wrapped in thick layers of bandages.  *goto Joey_respond

*else
    “I’ll admit, you got some moves,” he continues.  “I can respect a ${gender_refer} who knows how to throw down.  Didn’t amount to a hill of shit in the end, but them’s the breaks, eh?”
    *goto Joey_respond```

Your line in the second to last *if statement has the *goto at the end of the text and not on a separate line. Maybe that’s the problem?

That was exactly it! Inside CSIDE it was positioned so it looked like it was correct, but when I backspaced it moved a space. Weird, but very glad to resolve that.

Thanks a bunch!

Also: is the label in the goto directly underneath?

It is in this case, but I wasn’t aware that made a difference. I stick labels all over the place to be honest (my code is scary but it mostly makes sense to me, most of the time).

Aye :slight_smile:
When everything, as here, goes to the same bit, you do not need labels or *else. This below will work too:

Regular text
*if var1
   Text a
*if var2
   Text b
*if var3
   Text c
More regular text

If the last bit is meant to cover several other cases except those used at the ifs, then you need the gotos and labels:

Regular text
*if var1
   Text a
   *goto more
*elseif var2
   Text b
   *goto more
*elseif var3
   Text c
   *goto more
*else (<- this means for example var4 var 5 and var6)
   Text d
   *goto more
*label more
More text

If-elseif-else structures apply when a couple of variables values lead to different texts.

What you have might get wonky iirc as the else there only checks if it is different from the previous if, not all ifs, i think. Not 100% certain, as it should work as you do have gotos.

The else is only associated with the most recent if. In this particular scenario it works as is but the *goto is strictly required to behave the way you want; if Joey_shot and Paulie_dead are true and Paulie_burned is false, you’d get this without the gotos:

“I’m gonna start by payin’ you back for this,” he tells you, slightly raising his right arm which is bound in a crude sling.  “Hurts like a motherfucker.”
        
“Also,” he continues, “there’s the little matter of you blowing Paulie’s fuckin’ brains all over the room.  I can’t let somethin’ like that go.  I got a rep to maintain, after all.”

“I’ll admit, you got some moves,” he continues.  “I can respect a ${gender_refer} who knows how to throw down.  Didn’t amount to a hill of shit in the end, but them’s the breaks, eh?”

That’s very useful when you’re, say, recapping a series of separated events, but not what you want here.

Note that if-elseif-else guarantees exactly one of the blocks will be exercised, specifically the first one where the condition is true or the else block if none of the conditions are true. I’d recommend making the second and third ifs into elseifs on general principles but in this case that won’t have any impact on behavior.

Word wrapping can make it difficult sometimes. Always worth toggling it off if you’re having trouble finding problems with indentation.

2 Likes