Else, else, else...

Posted by Xemrel on July 14, 2006, 9:51 a.m.

You know. Gamemaker surprises me sometimes. It supports (simultaneously) the syntax of a bunch of different languages (Think of :=, =, and ==), and yet it can't handle multiple consecutive else statements. That seems especially odd, since it's written in Delphi, which supports multiple elses, so I would assume that Mr. O is at least aware of them, even if he doesn't use them regularly.

Anyway, the point is, I just tried to use multiple elses and it didn't accept them, and I'm sad, because now, what could (and should) have been one line is five lines.

PS: I still need a way to fool windows into seeing a network drive as if it were local. Hmm… Actually, I wonder… I might be able to create a SymLink (yes, XP does support them, it just has ne inteface for setting them up) to a network folder and then Subst that as an extra drive. Perhaps it wouldn't be smart enough then to realize that the SymLink isn't local… Wish me luck. ^_^

Comments

poultry 17 years, 9 months ago

O_o

if goodpeople=goodpeople2{

x=30

}else{

x=40

}else{

x=50

}

The first statement returns false, so it goes to the second else, … the second else never returns false, so then the third else is uesless

so it should be

if goodpeople=goodpeople2{

x=30

}else if goodpeople=goodpeople3{

x=40

}else{

x=50

}

poultry 17 years, 9 months ago

(Or a switch statement)

DesertFox 17 years, 9 months ago

you gotta have:

if(something){do something}

else if(something else){do something else}

else if(another something else){do another something else}

else{do another something else different}

like that - it's always worked for me; or you could always use switch statements!

poultry 17 years, 9 months ago

I BEAT YOU DF!!

DesertFox 17 years, 9 months ago

Crap.

Josea 17 years, 9 months ago

yeah, like Chiken said.

Why add that to GML when you can simply put an if after an else to make it look like a else if?

Josea 17 years, 9 months ago

one word…google

Polystyrene Man 17 years, 9 months ago

Um, I've used consecutive else statements tons of times. You just have to add 'if', as was mentioned above.

Xemrel 17 years, 9 months ago

Um, that's not at all what I meant. I understand that it can handle if then else if then else, and so on. I mean the word else <i>immediately</i> follows itself. as in…

<code>if something then if otherthing then x:=5 else else x:=23;</code>

…where x should stay the same if something is true, but otherthing is not.

poultry 17 years, 2 months ago

you fail at coding