Discuss Scratch

openPoll
Scratcher
1000+ posts

Elif (else-if) block

if <> then {
...
} 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
Like that?

Last edited by openPoll (March 6, 2019 12:54:07)

NilsTheBest
Scratcher
1000+ posts

Elif (else-if) block

openPoll wrote:

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

Elif (else-if) block

lucs100 wrote:

scimonster wrote:

mathfreak231 wrote:

First of all, nobody calls it Elif. It's “elseif” or “else if”.
Python users do, as that's the name of the Python keyword.

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!
Well you can use custom blocks for shorter. For this reason, no support.

(Actually a lot of ‘Elif’ blocks would also crash the server so it’s actually the same)
congyingzhou
Scratcher
1000+ posts

Elif (else-if) block

venyanwarrior wrote:

Support. I hate dragging and dropping a whole bunch of if then else blocks.
There IS the duplicate button.

openPoll wrote:

if <> then {
...
} 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
Like that?

Look at app inventor and do it like they do it
Truck11111
Scratcher
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.

Last edited by Truck11111 (May 13, 2019 14:48:31)

congyingzhou
Scratcher
1000+ posts

Elif (else-if) block

Truck11111 wrote:

No support, the workaround is easy, and what kind of name is “Elif?”
Agreed (though elif is in python)
imfh
Scratcher
1000+ posts

Elif (else-if) block

congyingzhou wrote:

Truck11111 wrote:

No support, the workaround is easy, and what kind of name is “Elif?”
Agreed (though elif is in python)
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.

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

Elif (else-if) block

It's an easy workaround.
FlappyTheBat
Scratcher
30 posts

Elif (else-if) block

frdsaw wrote:

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 <> then

else

end
blocks and it is pretty annoying so
posyhm08
Scratcher
10 posts

Elif (else-if) block

|- If <> then
|
|
|
|- else If <> then
|
|
|
|————-

Last edited by posyhm08 (May 12, 2019 08:52:32)

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

Elif (else-if) block

No support. We already have a workaround for this:
if <foo> then 

...

else
if <bar> then
...
end
end
This is the same reason that the
forever if <> ::control

end
block was removed; it already had a workaround with
forever
if <> then

end
end
NilsTheBest
Scratcher
1000+ posts

Elif (else-if) block

MG-AL wrote:

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
“elif” would need to be a c-block, not a stack….
imfh
Scratcher
1000+ posts

Elif (else-if) block

findanegg wrote:

No support. We already have a workaround for this:
-snip-
This is the same reason that the
forever if <> ::control

end
block was removed; it already had a workaround with
forever
if <> then

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

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

Elif (else-if) block

Support this would make code a lot less messy
MrFluffyPenguins
Scratcher
1000+ posts

Elif (else-if) block

if <> then 
if <> then



else

end


else

end
Problem solved.
ggenije
Scratcher
500+ posts

Elif (else-if) block

Workaround which I have been using for a long time:
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
Scratcher
26 posts

Elif (else-if) block

In python, there is a thing you can do called else-if, it looks like this:
if <...> then 



else if <...>then

end
I think this would be extremely useful for scratch, as it would make things easier to code. however, you can still do things like this:
if <...> then 



else
if <...> then

end
end

Powered by DjangoBB