Discuss Scratch
- Extremguy
-
100+ posts
For Loop
Scratch team should definitly add these loop and lemme explain. I know there are aleardy the “Repeat (number) of times” or repeat until stuff is done , but I think that we need the implementation of a for loop , because we wont need to have all time to create new freaking variable to check a list. So list handling will be way more easier within' a good ol' for loop. Please add for loop that have their own variable inside like for example
for myVariable(of the loop no need to create a new one on the side) = 2 do
stuff
end
for myVariable(of the loop no need to create a new one on the side) = 2 do
stuff
end
- DownsGameClub
-
1000+ posts
For Loop
Wouldn't this be sort of like the
I find this opening way too confusing. What is your suggestion? Loops do have to stop at some point.
foreverblock?
end
I find this opening way too confusing. What is your suggestion? Loops do have to stop at some point.
Last edited by DownsGameClub (June 16, 2016 19:00:40)
- TheHockeyist
-
1000+ posts
For Loop
They're saying that if something is true, then do it.
That's like the if block shown below.
That's like the if block shown below.
if <(condition) = [true]> then
do something
end
- MathlyCat
-
1000+ posts
For Loop
I'd like to point something out:
Since it's a forever loop around the if block it will execute the provided is true (or just use a repeat until not combo)
For loops wouldn't add very much into Scratch in the first place due to it's functions being usuable through other blocks; workarounds.
No support.
forever
if <(this) = [1 ]> then
end
end
Since it's a forever loop around the if block it will execute the provided is true (or just use a repeat until not combo)
For loops wouldn't add very much into Scratch in the first place due to it's functions being usuable through other blocks; workarounds.
No support.
- gdpr533f604550b2f20900645890
-
1000+ posts
For Loop
Both of you misunderstand the suggestion. A for loop is a loop which executes the body a certain amount of times, incrementing a variable after each iteration.
A variable called i is initialized to 0 when the loop is entered. Before each iteration, the interpreter checks if i is less than 10. If the condition is false, the loop is stopped. After each iteration, i is incremented.
However, the OP mentions lists, and not creating variables, so I assume that they want for-each loops. These are similar to for-loops, but instead of using a counter variable, they execute the body “for each” element in the array.
I support this suggestion.
EDIT: I was ninja'd by MathlyCat, who also seems to misunderstand the suggestion.
for(var i = 0; i < 10; i++) { }
A variable called i is initialized to 0 when the loop is entered. Before each iteration, the interpreter checks if i is less than 10. If the condition is false, the loop is stopped. After each iteration, i is incremented.
However, the OP mentions lists, and not creating variables, so I assume that they want for-each loops. These are similar to for-loops, but instead of using a counter variable, they execute the body “for each” element in the array.
I support this suggestion.
EDIT: I was ninja'd by MathlyCat, who also seems to misunderstand the suggestion.
Last edited by gdpr533f604550b2f20900645890 (June 16, 2016 19:14:27)
- Extremguy
-
100+ posts
For Loop
It not forever and if m'kay. I dont know why you people are integreating if condition inside of your script , because do you know what is a for loop. With a for loop I can check condition by using lists without condition (I'm sorry if it sound complicated)
for example I have a list named to condition
and in that list I have some condition that need to be met by other list
so I have my list that are like a list of stuff that need to match the condition list
and then my for loop will trigger through the list to see if the condition match using a block.
for example I have a list named to condition
and in that list I have some condition that need to be met by other list
so I have my list that are like a list of stuff that need to match the condition list
and then my for loop will trigger through the list to see if the condition match using a block.
- TheHockeyist
-
1000+ posts
For Loop
Both of you misunderstand the suggestion. A for loop is a loop which executes the body a certain amount of times, incrementing a variable after each iteration.for(var i = 0; i < 10; i++) { }
A variable called i is initialized to 0 when the loop is entered. Before each iteration, the interpreter checks if i is less than 10. If the condition is false, the loop is stopped. After each iteration, i is incremented.
However, the OP mentions lists, and not creating variables, so I assume that they want for-each loops. This is similar to a for-loop, but instead of using a counter variable, executes the body “for each” element in the array.
I support this suggestion.
EDIT: I was ninja'd by MathlyCat, who also seems to misunderstand the suggestion.
That would just be repeat x times, increasing i by one each time until i = x.
We can already do that; no support.
Last edited by Paddle2See (April 21, 2021 21:19:37)
- gdpr533f604550b2f20900645890
-
1000+ posts
For Loop
Is “iterate” the word that you are looking for? It not forever and if m'kay. I dont know why you people are integreating if condition inside of your script , because do you know what is a for loop. With a for loop I can check condition by using lists without condition (I'm sorry if it sound complicated)
for example I have a list named to condition
and in that list I have some condition that need to be met by other list
so I have my list that are like a list of stuff that need to match the condition list
and then my for loop will trigger through the list to see if the condition match using a block.
These aren't the droids you're looking for. :P
- MathlyCat
-
1000+ posts
For Loop
I myself like for loops but haven't used one in a while; also don't complain at us, I read your suggestion, no offense, but it was poorly explained. It not forever and if m'kay. I dont know why you people are integreating if condition inside of your script , because do you know what is a for loop. With a for loop I can check condition by using lists without condition (I'm sorry if it sound complicated)
for example I have a list named to condition
and in that list I have some condition that need to be met by other list
so I have my list that are like a list of stuff that need to match the condition list
and then my for loop will trigger through the list to see if the condition match using a block.
Chibi, I was thinking of that but absolutely forgot the variable part; assuming it's crucial to the for loop.
Support.
- gdpr533f604550b2f20900645890
-
1000+ posts
For Loop
Sorry, but I beg to differ. Scratch has a serious variable cluttering problem due to a lack of script and loop scopes. The OP mentions the annoyance of littering the blocks palette with variables. Many languages have for-each loops for iterating over arrays. That would just be repeat x times, increasing i by one each time until i = x.
We can already do that; no support.
- gdpr533f604550b2f20900645890
-
1000+ posts
For Loop
Based on the description, I believe that the OP actually wants for-each loops. They mention the problem which exists about creating variables in Scratch, and for-loops still use variables. I myself like for loops but haven't used one in a while; also don't complain at us, I read your suggestion, no offense, but it was poorly explained.
Chibi, I was thinking of that but absolutely forgot the variable part; assuming it's crucial to the for loop.
Support.
- gdpr533f604550b2f20900645890
-
1000+ posts
For Loop
Is this what you want?
for each (item) in [list v]::cstart controlThe item variable is an upvar which can be dragged.
end
- Extremguy
-
100+ posts
For Loop
People who disagree ,when you will do some project containing lots of list and lots variable you will understand that it really annoying to have ten thousand billionth of freaking global/sprite variable in your variable list because of dem freaking loop. When you are checking the element of a list you need a variable to check all of them one by one and it wont do itself just with this block:
It's because we need a variable to check in all because there are no for loop.
Go see my project and you will understand what I mean by messy variable . We need for loop.
Here's a basic example of a loop without the for that have to check all the stuff
https://scratch-mit-edu.ezproxyberklee.flo.org/projects/113789736/
In other language , when you have a for loop the new var inside of the for loop is hold by the for loop and there wont have to be a new var set in your top area where you set your var.
repeat ()
end
It's because we need a variable to check in all because there are no for loop.

Here's a basic example of a loop without the for that have to check all the stuff
https://scratch-mit-edu.ezproxyberklee.flo.org/projects/113789736/
In other language , when you have a for loop the new var inside of the for loop is hold by the for loop and there wont have to be a new var set in your top area where you set your var.
- gdpr533f604550b2f20900645890
-
1000+ posts
For Loop
I support loops such as for and for-each, with upvars. I would also like script and loop scopes for variables.

Please be constructive and say why you don't support. No support

Last edited by gdpr533f604550b2f20900645890 (June 16, 2016 19:24:55)
- MathlyCat
-
1000+ posts
For Loop
A useful resource for you to use would be: No support
This should be read before making a reply on this forum
Thanks,

- DownsGameClub
-
1000+ posts
For Loop
Oh, so you are suggesting a
(Supposed to be a loop…)
For <>:: Controlblock?
end
(Supposed to be a loop…)
Last edited by DownsGameClub (June 16, 2016 19:58:34)
- Sigton
-
1000+ posts
For Loop
For anyone who has used a text-based language properly, you'll know how useful for loops are 
For example, if I was to have the following python code:
Then the output would be this:
So you see how useful they are. I give full support.
Sigton
EDIT: I thought I'd show what it would be like without for loops.

For example, if I was to have the following python code:
my_array = [ item1, item2, item3, item4 ] for item in my_array: print(item) # item would equal "item1" on first iteration, "item2" on second iteration and so on.
>>> item1
>>> item2
>>> item3
>>> item4
>>>
Sigton
EDIT: I thought I'd show what it would be like without for loops.
my_array = [ item1, item2, item3, item4 ] n = 0 while n < len(my_array): print(my_array[n]) n += 1 # n is increased by 1 every iteration, and then prints item n of my array
Last edited by Sigton (June 16, 2016 20:13:44)