# for items in range [] ([]) loop

I implemented a loop similar to python's

for i in range[]


loop. For those who do not know what that loop does, its function is to do something for the number of numbers from 0 to the range you have used.
Here is the project's source code:
. Embed:

You can press t and o keys to play with the loop. This was supposed to my best custom block ever but then I found that Jens suggested @kimmie46 to use my method months ago when he was trying to implement the same thing as me. :man_facepalming:

(I wish I never have to write documentation as part of my profession. This is so hard. I wished to write so much but failed.)

The numbers in the ranges are inaccessible.

Get used to it. It's a big part of every programmer's job, and most of them hate it, but there's no point writing a program that nobody can use.

Sometimes you can put a mini-tutorial in the program instead of writing a separate document. It's all the rage these days to pop up a little box that points to a button and says what that button does, and you get options "next" and "skip this tutorial."

If you're really on the ball, you write two documents, one for users (that's the hard one) and one for the programmer who takes over maintenance of your code when you leave the job. That's what I did for Berkeley Logo. In Snap! I'm in charge of user documentation and Jens is in charge of programmer documentation.

Don't you want an upvar in your block that holds the current number? Basically what you're doing is like our FOR block, and it has an upvar.

One other minor critique: Because you said "items" in the title and because the block is red, I expected it to operate on a list, like FOR EACH ITEM. Even though you use NUMBERS FROM in the implementation, from the user's perspective there's no list involved, just numbers.

What do you mean?

Yes, of course.

That is quite easy, in my opinion.

This is the first time I am hearing of upvars. What is that?

I do not understand this either. "numbers from () to ()" does return a list.

Try using your blocks to say the numbers from 1 to 10.

It works for me. What does it do when you try it?

Show me what you did.

I think I know what you want to say, the project does not exist. It looks like sharing from the editor did not work.

You should be able to view that now.

[scratchblocks]
for items in range [1] [10] {
say [] for (1) secs
}
[/scratchblocks]
did not do that.

I still see the project the same way it was before.

I really do not understand what your code is supposed to do. It looks like you want to say nothing so that should not do anything.

Yes; I still see the same two scripts.

Why do your blocks reference ranges if we can't access them?

What do you mean by

?

Have you tried remixing it (the original project)?

...
There is no way for me to use the block to say the numbers from 1 to 10. There is no upvar, and it doesn't pass the numbers to the script, so the input remains empty. I would need a separate variable and incrementer to say the numbers from 1 to 10 in your blocks.
(reply is late because I was busy)

I need to understand what that is to answer you, of course! But I think I do understand what point you and @dardoro (and maybe @bh, too) are trying to make. So, I have updated the block definition. Thank you very much!