[Thread Prev] [Thread Next]
On Wed, 08 Feb 2012 11:51:19 -0500, Dawn Young <YoungD@xxxxxxxxxxxxxxxxxxxxx>
I am using MicroWorlds EX Robotics. My 8th grade students are creating line
segments from a central point so it looks like spokes of a wheel. I'd like
them to have a text box at the end of each spoke that eventually has the
heading for that spoke printed into it. Is there a way to have the textbox
name be a variable that gets changed each repetition?
Repeat 10 [fd 100 bk 100 text 1, pr heading rt 36]
Use dotimes if you want a "counter"
dotimes [i 10] [show :i]
Then, you want to create text boxes through programming. Use newtext
But newtext doesn't like the names of text boxes to be bare numbers. Use
dotimes [i 4] [show word "mytextbox :i]
Take a look at PlaceTextBoxes.mwx attached.
Text1 I want to become text2 for the second repetition rather than have a
list of each heading in one box.
Do you know that there is serious discussion about which should be the first
ordinal number, 1 or 0?
"dolist" thinks it is 0.
I am also experimenting with the same idea for coloring spokes of different
colors...setc :color+1 kind of idea with the color variable being a number.
the ***command*** color outputs the color of the current turtle.
so you can say:
setc 1 + color
command *color*, please tell me what is the color of the current turtle.
operator *plus*, add 1 to that value.
command *setc*, please set the color of the current turtle to that.
I know I can do this with a line of logo code for each spoke, but was hoping
there was a way to use it within repeat. Any ideas?
The problem with REPEAT is that inside the list of commands repeatedly run by
REPEAT you don't know which repetition you are current running.... unless you
use variables, or other variable-like thingies.
Using DOTIMES [i 10] [...] you *do* know which repetition you are currently
running: the variable :i tells you.
Previous by thread:
textbox name variables? color number variables?
Next by thread:
Re: Hello / MW question
To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.