Discuss Scratch
- bozman
-
73 posts
Else If
An Else If block would be extremely useful. Yes, there is stacking ifs… but an else if would make it shorter and easier to work with.
example:
if (condition)
do something
else if (condition)
do something else
else
do something else
example:
if (condition)
do something
else if (condition)
do something else
else
do something else
Last edited by bozman (March 1, 2014 03:33:26)
- Firedrake969
-
1000+ posts
Else If
Support. It's also used in JavaScript. Maybe Scratch would have an expandable (literally) if block for the if/else if/else if?
Javascript:
etc.
It's sort of like many If/Else blocks nested inside each other.
Python: Please make what you are stating clearer.
if condition:
stuff
elif condition2:
stuff2
elif condition3:
stuff3
Javascript:
if (condition) {
stuff
} else if (condition2) {
stuff2
} else if (condition3) {
stuff3
}
etc.
It's sort of like many If/Else blocks nested inside each other.
- AonymousGuy
-
1000+ posts
Else If
Maybe…
But I would call it elseif because that's clearer and more widely used in other languages.
But I would call it elseif because that's clearer and more widely used in other languages.
Last edited by AonymousGuy (Feb. 27, 2014 02:46:55)
- Sonickyle
-
1000+ posts
Else If
if <> then
else
if <> then
end
end
Last edited by Sonickyle (Feb. 27, 2014 13:38:58)
- firedrake969_test
-
500+ posts
Else If
What if you need around ten to twenty? It's certainly a possible case, and the scripting interface becomes way too cluttered with the one if/else if/else if statement.if <> then
else
if <> then
end
end
- ev3commander
-
500+ posts
Else If
What if you need around ten to twenty? It's certainly a possible case, and the scripting interface becomes way too cluttered with the one if/else if/else if statement.if <> then
else
if <> then
end
end
if <[condition1] = [true]> then…You get the idea.
blah
else
if <[condition2]= [false]> then
blah
end
if <[condition3] = [true]> then
blah
end
end
Last edited by ev3commander (Feb. 28, 2014 01:44:35)
- firedrake969_test
-
500+ posts
Else If
Like I said, it gets too big and cluttered, and doesn't work the same was as if/else if/else.
- mathfreak231
-
1000+ posts
Else If
Of course don't call it “elif”. The name just sounds bad to me and it would be 100% confusing.
- firedrake969_test
-
500+ posts
Else If
Of course don't call it “elif”. The name just sounds bad to me and it would be 100% confusing.
Yeah, I'd do something like this Maybe…
But I would call it elseif because that's clearer and more widely used in other languages.
if
else if <> v x
else if <> v x
v to create another else/if, and x to remove that one.
- AonymousGuy
-
1000+ posts
Else If
That would probably be good. I made a mockup with a similar idea: Yeah, I'd do something like this
if
else if <> v x
else if <> v x
v to create another else/if, and x to remove that one.

- Firedrake969
-
1000+ posts
Else If
Thanks, that's what I was trying to say 
I think the up arrow should be a little x, though.

I think the up arrow should be a little x, though.
- ScratchJahd2011
-
500+ posts
Else If
I understand now, since it is not cluttering, and it is used by other programming languages.
Support.
Support.
- Gigabyte_Giant
-
43 posts
Else If
I think this would be a good thing to add. I think that allowing multiple condition checks, in one if statement, allows me more control over my code.
Certainly, if you want to check for 10 or 20 conditions, you should most likely center it around a single variable… One pretty easy way to do this, is via a switch statement. It has yet to have been implemented into Scratch, but I did suggest it to the Scratch team. (See forum topic below.)
http://scratch.mit.edu.ezproxyberklee.flo.org/discuss/topic/31108/
I support this all the way, as I would like to be able to check more conditions in one block.
What if you need around ten to twenty? It's certainly a possible case, and the scripting interface becomes way too cluttered with the one if/else if/else if statement.if <> then
else
if <> then
end
end
Certainly, if you want to check for 10 or 20 conditions, you should most likely center it around a single variable… One pretty easy way to do this, is via a switch statement. It has yet to have been implemented into Scratch, but I did suggest it to the Scratch team. (See forum topic below.)
http://scratch.mit.edu.ezproxyberklee.flo.org/discuss/topic/31108/
I support this all the way, as I would like to be able to check more conditions in one block.
- xlk
-
100+ posts
Else If
Support.
Also, the “C” blocks lag the editor the most. huge ones, like 12 of them, within each other kill the editor
Also, the “C” blocks lag the editor the most. huge ones, like 12 of them, within each other kill the editor

- blob8108
-
1000+ posts
Else If
Mockup, just for fun:
if <> thenEDIT: I think this would probably be a right-click menu option – “add condition” – if it were implemented.
else if <> then :: celse
else if <> then :: celse
end
Last edited by blob8108 (March 1, 2014 21:32:04)
- ev3commander
-
500+ posts
Else If
What would it look like, anyway?
else if<>and would be only allowed in if blocks?
- ev3commander
-
500+ posts
Else If
Mockup, just for fun:if <> thenEDIT: I think this would probably be a right-click menu option – “add condition” – if it were implemented.
else if <> then :: celse
else if <> then :: celse
end
if <> then
else if <> then v x :: celse
else if <> then v x :: celse
end