Discuss Scratch
- Discussion Forums
- » Suggestions
- » Elif (else-if) block
- openPoll
-
1000+ posts
Elif (else-if) block
if <> then {Like that?
...
} else if <> then ((- :: control) :: grey ring) {
...
} else if <> then ((- :: control) :: grey ring) {
...
} else if <> then ((- :: control) :: grey ring) {
...
} else if <> then ((- :: control) :: grey ring) {
...
} else ((- :: control) :: grey ring) {
...
} ((+ :: control) :: grey ring) :: control
Last edited by openPoll (March 6, 2019 12:54:07)
- NilsTheBest
-
1000+ posts
Elif (else-if) block
-snip-You can use “@delInput” and “@addInput” to recreate the following:
@delInput @addInput :: #ffffff
This feels like the Offical Scratchblocks testing topic, tbh XD
Last edited by NilsTheBest (March 6, 2019 13:00:12)
- imfh
-
1000+ posts
Elif (else-if) block
This would be tricky in the Scratch 3.0 file format. Each input in a Scratch has a name. As illustrated by the normal if else block below, this is normal CONDITION, SUBSTACK, and SUBSTACK2.
If “if elif else” was 1 block, there would be an unlimited number of inputs. It would require something like what custom blocks currently have to create a custom input list.
What if instead of being 1 block, it only rendered as if it was 1 block? When an “if else” is the first block under “else,” it would render like 1 block. Blocks could still be placed between them causing them to separate. This would have the added advantage of existing projects getting the effects right away.
Either way would still be hard to implement, but it would be pretty nifty.
if <CONDITION :: grey> then
SUBSTACK :: grey
else
SUBSTACK2 :: grey
end
If “if elif else” was 1 block, there would be an unlimited number of inputs. It would require something like what custom blocks currently have to create a custom input list.
if <CONDITION :: grey > then {
SUBSTACK :: grey
} else if <CONDITION ? :: grey > then {
SUBSTACK ? :: grey
} else {
SUBSTACK ? :: grey
} :: control
What if instead of being 1 block, it only rendered as if it was 1 block? When an “if else” is the first block under “else,” it would render like 1 block. Blocks could still be placed between them causing them to separate. This would have the added advantage of existing projects getting the effects right away.
if <CONDITION :: grey> then
SUBSTACK :: grey
else
if <CONDITION :: grey> then // SUBTACK2
SUBSTACK :: grey
else
SUBSTACK2:: grey
end
end
Either way would still be hard to implement, but it would be pretty nifty.
- congyingzhou
-
1000+ posts
Elif (else-if) block
Well you can use custom blocks for shorter. For this reason, no support.Python users do, as that's the name of the Python keyword. First of all, nobody calls it Elif. It's “elseif” or “else if”.
What's wrong with simply stacking if/elses?if <...> then
...
else
if <...> then
...
else
if <...> then
...
else
if <...> then
...
else
...
Well, in this Project that I made, using that many else / if blocks was extremely annoying and painstaking. To give the user more chances before crashing (see inside the project) would make it 12 or more else / if blocks thick!
(Actually a lot of ‘Elif’ blocks would also crash the server so it’s actually the same)
- congyingzhou
-
1000+ posts
Elif (else-if) block
There IS the duplicate button. Support. I hate dragging and dropping a whole bunch of if then else blocks.
if <> then {Like that?
...
} else if <> then ((- :: control) :: grey ring) {
...
} else if <> then ((- :: control) :: grey ring) {
...
} else if <> then ((- :: control) :: grey ring) {
...
} else if <> then ((- :: control) :: grey ring) {
...
} else ((- :: control) :: grey ring) {
...
} ((+ :: control) :: grey ring) :: control
Look at app inventor and do it like they do it
- Truck11111
-
1000+ posts
Elif (else-if) block
i have no clue if i support or not
No support, the workaround is easy, and what kind of name is “Elif?”
Support, although I haven't ever had to use it, I probably will soon.
No support, the workaround is easy, and what kind of name is “Elif?”
Support, although I haven't ever had to use it, I probably will soon.
Last edited by Truck11111 (May 13, 2019 14:48:31)
- congyingzhou
-
1000+ posts
Elif (else-if) block
Agreed (though elif is in python) No support, the workaround is easy, and what kind of name is “Elif?”
- imfh
-
1000+ posts
Elif (else-if) block
I assume neither of you have had to switch case between a large number of choices. I mean, it gets pretty ridiculous when the lines of if to the left are wider than the ifs themself.Agreed (though elif is in python) No support, the workaround is easy, and what kind of name is “Elif?”
It doesn't have to be exactly like suggested; I think most people agree that else if would be better for Scratch. If you look above, I've suggested that this only be a visual change.
When a if else block is in the else of another block with nothing between, they could merge into one. They could then be separated by placing a block between.
if <> then
else
move (...) steps
if <> then // This would not merge
else
end
end
if <> then
else
if <> then // This would merge in an if, if else, else
else
end
end
- ChiaJia
-
62 posts
Elif (else-if) block
No support, working around this is easy enough. I also agree with other Scratchers who say that an elif block might confuse New Scratchers.
- FlappyTheBat
-
30 posts
Elif (else-if) block
I suggest adding an Elif (else-if) Block so you don't have to have numerous else and if blocks. I also suggest, with this, that you can change the elif amount ( making it changeable by length through numbers as part of the elif block.).
I hope you take this into account, as I would find it very useful.(Feels like a speech! XD)
Yes, it sounds great! I have this game where there are SOOOOOOOOOOOOOO many
if <> thenblocks and it is pretty annoying so
else
end



































- posyhm08
-
10 posts
Elif (else-if) block
|- If <> then
|
|
|
|- else If <> then
|
|
|
|————-
|
|
|
|- else If <> then
|
|
|
|————-
Last edited by posyhm08 (May 12, 2019 08:52:32)
- MG-AL
-
30 posts
Elif (else-if) block
when green flag clicked
if <Boolean> then
do something
elif <Boolean> then
do something
else <Boolean> then
do something
+
end
How about this design? The + adds an elif
Last edited by MG-AL (May 12, 2019 19:01:00)
- findanegg
-
500+ posts
Elif (else-if) block
No support. We already have a workaround for this:
if <foo> thenThis is the same reason that the
...
else
if <bar> then
...
end
end
forever if <> ::controlblock was removed; it already had a workaround with
end
forever
if <> then
end
end
- NilsTheBest
-
1000+ posts
Elif (else-if) block
“elif” would need to be a c-block, not a stack….when green flag clicked
if <Boolean> then
do something
elif <Boolean> then
do something
else <Boolean> then
do something
+
end
How about this design? The + adds an elif
- imfh
-
1000+ posts
Elif (else-if) block
The workaround for “forever if” is not comparable too this. With forever if, you don't ever need to use multiple forever ifs inside each other. With if, else if, however, you may need to use a ton of if statements stacked inside each other. This makes the workaround very messy at times. No support. We already have a workaround for this:
-snip-
This is the same reason that theforever if <> ::controlblock was removed; it already had a workaround with
endforever
if <> then
end
end
forever
if <> then
forever // You rarely need another, just use wait until
if <> then
end
end
end
end
if <> then // Sorry this is a bit blockspammy; it's to prove the point
else
if <> then // With just 5 conditions, you can quickly see that this gets messy.
else
if <> then // Switch cases like this are much more commonly used than forever if.
else
if <> then // The bars on the side are now nearly as wide as an empty if then block.
else
if <> then // Wouldn't it be nice if these would automatically merge into one block?
else
… // Be glad I didn't decide to do 15 of these...
end
end
end
end
end
- --Explosion--
-
1000+ posts
Elif (else-if) block
Support this would make code a lot less messy
- MrFluffyPenguins
-
1000+ posts
Elif (else-if) block
if <> thenProblem solved.
if <> then
else
end
else
end
- ggenije
-
500+ posts
Elif (else-if) block
Workaround which I have been using for a long time:
That way you can easily add/remove new IF blocks and choose order
define Elif workaround (variable)
if <(variable :: #5a45ac ) = [1]> then
Do whatever for 1
stop [this script v]
end
if <(variable :: #5a45ac ) = [2]> then
Do whatever for 2
stop [this script v]
end
if <(variable :: #5a45ac ) = [3]> then
Do whatever for 3
stop [this script v]
end
if <(variable :: #5a45ac ) = [4]> then
Do whatever for 4
stop [this script v]
end
...
if <(variable :: #5a45ac ) = [N]> then
Do whatever for N
stop [this script v]
end
That way you can easily add/remove new IF blocks and choose order
Last edited by ggenije (Sept. 8, 2019 08:20:59)
- balmerazTSC
-
26 posts
Elif (else-if) block
In python, there is a thing you can do called else-if, it looks like this:
if <...> thenI think this would be extremely useful for scratch, as it would make things easier to code. however, you can still do things like this:
else if <...>then
end
if <...> then
else
if <...> then
end
end