Discuss Scratch
- LOLScratch12233
-
Scratcher
100+ posts
For Loop
They're saying that if something is true, then do it.
That's like the if block shown below.if <(condition) = [true]> then
…
end
They're saying that if something is true, then do it.
That's like the if block shown below.if <(condition) = [true]> then
do something
end
- kccuber
-
Scratcher
1000+ posts
For Loop
would it look like this?
for each [foo v] in (3) {
...
} :: controlor this?for (foo) = (2) to (7) {
...
} :: control // you would be able to drag out the (foo)and for good measure, why not this too?for (item) in [list v] {
...
} :: list- medians
-
Scratcher
1000+ posts
For Loop
like this:
for(let i = 0; i < 4; i++ //would do i = i + 1) {would log in this order:
console.log(i);
}
0
1
2
3
for(let i = 4; i > 0; i– //would do i = i - 1) {would log in this order:
console.log(i);
}
4
3
2
1
for(let i = 0; i < 4; i += 2 //would do i = i + 2) {would log in this order:
console.log(i);
}
0
2
for(let i = 4; i > 0; i -= 2 //would do i = i - 2) {would log in this order:
console.log(i);
}
4
2
- mumu245
-
Scratcher
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.True.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.
Also, this is already implemented, but hidden.
for each [ v] in (){
} ::controlLast edited by mumu245 (Sept. 23, 2021 12:45:53)
- LOLScratch12233
-
Scratcher
100+ posts
For Loop
I have loop blocks:
forever
end
while<>{
}::control
for each [foo v] in (10){
}::control
- SuperMarioHome
-
Scratcher
100+ posts
For Loop
Workaround
set [i v] to (0)
repeat (. . . :: grey)
. . .
change [i v] by (1)
end
- dave-alt-4
-
Scratcher
1000+ posts
For Loop
for loop? like (qbasic)
isn't that doable with
a = 1
FOR a = 1 TO 5
PRINT a
NEXT a
set [a v] to [1]
repeat until (not <(a) < [6]> )
say [a]
change [a] by (1)
- -EmeraldThunder-
-
Scratcher
1000+ posts
For Loop
isn't that doable withTechnically yes but it's a hassle to create the variables and also feels a little bit clumsy with having to increment the variable yourself every time. A for loop would be so much neater.
- dave-alt-4
-
Scratcher
1000+ posts
For Loop
uSe CuStOm BlOcKs no support support since new scratchers probably don't know how to use custom blocks
Last edited by dave-alt-4 (Nov. 29, 2021 06:43:37)
- historical_supa
-
Scratcher
1000+ posts
For Loop
support, this would make scrolling projects and lots of others more simpler
- ideapad-320
-
Scratcher
1000+ posts
For Loop
it would be
repeat () times{
...
}storing the loop number in[my variable v]::control- VeryFamus
-
Scratcher
1000+ posts
For Loop
it would beThat seems like a very oversized C block.repeat () times{
...
}storing the loop number in[my variable v]::control
And, I might be wrong, but this suggestion seems to be wanting to add a block that does this:
repeat (insert variable)But, seeing as how it’s in the block palette, just hidden, this doesn’t seem like it would be a very bad thing to add.
…
end
- ScolderCreations
-
Scratcher
1000+ posts
For Loop
I am absolutely astounded. Just amazing. I cannot believe this topic survived so many years despite the fact that it already exists. That's right, scratch already has a for loop that includes variables. However, it's hidden from the block pallette, which basically means you can't find it unless someone makes a project including it. Therefore, if the suggestion means just add the block back to the list, then yeah, I support.
- RediblesQW_Doors
-
Scratcher
38 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.kfor(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.
- cookieclickerer33
-
Scratcher
1000+ posts
For Loop
it shouldnt use =
the = isnt a math equal to like 5 = 5
in js and python the = is how you define/set a variable so what it really is saying is
for each (var) set var to (1) to (10)
is not
for each (var) equal to (1) to (10)
its really
for each (number) in (1) to (10)
i see the = being used incorrectly in mods that have this block because they think it means the former
so the block should be called
the = isnt a math equal to like 5 = 5
in js and python the = is how you define/set a variable so what it really is saying is
for each (var) set var to (1) to (10)
is not
for each (var) equal to (1) to (10)
its really
for each (number) in (1) to (10)
i see the = being used incorrectly in mods that have this block because they think it means the former
so the block should be called
set [var v] for each num in (1) to (10){
}::control















