Break and Continue Blocks + Naming Control Flow Statements

Pretty cool idea

2 Likes

Coolios.

2 Likes

I think it will be harder for the devs to implement this. Especially since ‘break’ would have to ‘automatically’ end the repeat block even if it hasn’t finished. Either way, it would be perfect addition, and it would also make the code more efficient. It would be very useful for objects with moving animations like ‘move forward [300]’, which if tapped would originally need to wait for the loop to end before resetting its own animation.

4 Likes

That’s why there would be “check once if else” inside repeat forever blocks.

Example:

Repeat Forever:
Check once if: -1 = Supreme
Set Text: “Petrichor is Supreme”
else:
break
…and then whatever would be after.

2 Likes

Also, I think there should be an option to ‘broadcast’ named statements. Because most programming language uses ‘void’ (text) or ‘when broadcasted’ (blocks).

2 Likes

The beta editor has a broadcast block. I don’t know if it does exactly what you’re saying one should do, though.

2 Likes

The kind that’s used in real programming, except it has ‘void’ next to a function and it is basically a set of code that doesn’t run until it gets called. The broadcast feature in the beta is probably for the chat bot.

2 Likes

I don’t have the beta, so I have no idea if it is or not.

2 Likes

We do have ‘when ()=()’ which somewhat does the same thing, your example just makes it even easier to code.

2 Likes

Types would be nice
Then we can make strutcts

I think there are 100+ blocks the devs could add to Hopscotch including your ‘break’ and ‘continue’ blocks, and if there was that many more blocks, there should be better organization, as well as a ‘search blocks’ feature.

1 Like

However, we must remember that this is a kids’ coding app, and as such there cannot be too many blocks, as remembering how all of them function would be difficult for a lot of 8-12 year olds.

1 Like

Oyes that is true
What if there was a “beginners set” and a “complete set”

And maybe a “favorites” to save your favorites

1 Like

Oh please do add this THT. It would be super helpful for stopping repeat forever loops and checking if music is paused.

3 Likes

Oh yeah, it would be really useful for music. I didn’t think about that.

2 Likes

oh yeah
I forgot about they have repeat forever loops

With “break” we could turn this repeat forever into a “while” loop or “repeat until” block.

2 Likes

yess

1 Like

Yes! Absolutely! I would love to see this.

1 Like

we need these

Excellent idea!

This is also used in Python,

while True:
    if value == 0:
        break
1 Like