Discuss Scratch

bozman
Scratcher
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

Last edited by bozman (March 1, 2014 03:33:26)

ScratchJahd2011
Scratcher
500+ posts

Else If

Please make what you are stating clearer.
Firedrake969
Scratcher
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?

ScratchJahd2011 wrote:

Please make what you are stating clearer.
Python:
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
Scratcher
1000+ posts

Else If

Maybe…

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
Scratcher
1000+ posts

Else If

if <> then    
else
if <> then

end
end

Last edited by Sonickyle (Feb. 27, 2014 13:38:58)

firedrake969_test
Scratcher
500+ posts

Else If

Sonickyle wrote:

if <> then    
else
if <> then

end
end
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.
ev3commander
Scratcher
500+ posts

Else If

firedrake969_test wrote:

Sonickyle wrote:

if <> then    
else
if <> then

end
end
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 <[condition1] = [true]> then
blah
else

if <[condition2]= [false]> then
blah
end
if <[condition3] = [true]> then
blah
end
end
…You get the idea.

Last edited by ev3commander (Feb. 28, 2014 01:44:35)

firedrake969_test
Scratcher
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
Scratcher
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
Scratcher
500+ posts

Else If

mathfreak231 wrote:

Of course don't call it “elif”. The name just sounds bad to me and it would be 100% confusing.

AonymousGuy wrote:

Maybe…

But I would call it elseif because that's clearer and more widely used in other languages.
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.
AonymousGuy
Scratcher
1000+ posts

Else If

firedrake969_test wrote:

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.
That would probably be good. I made a mockup with a similar idea:
Firedrake969
Scratcher
1000+ posts

Else If

Thanks, that's what I was trying to say

I think the up arrow should be a little x, though.
ScratchJahd2011
Scratcher
500+ posts

Else If

I understand now, since it is not cluttering, and it is used by other programming languages.

Support.
Gigabyte_Giant
Scratcher
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.

firedrake969_test wrote:

Sonickyle wrote:

if <> then    
else
if <> then

end
end
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.

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
Scratcher
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
blob8108
Scratcher
1000+ posts

Else If

Mockup, just for fun:
if <> then
else if <> then :: celse
else if <> then :: celse
end
EDIT: I think this would probably be a right-click menu option – “add condition” – if it were implemented.

Last edited by blob8108 (March 1, 2014 21:32:04)

mathfreak231
Scratcher
1000+ posts

Else If

How about instead of arrows, there is a + and a -?
ev3commander
Scratcher
500+ posts

Else If

What would it look like, anyway?
else if<>
and would be only allowed in if blocks?
ev3commander
Scratcher
500+ posts

Else If

blob8108 wrote:

Mockup, just for fun:
if <> then
else if <> then :: celse
else if <> then :: celse
end
EDIT: I think this would probably be a right-click menu option – “add condition” – if it were implemented.
if <> then
else if <> then v x :: celse
else if <> then v x :: celse
end

Powered by DjangoBB