|
Part
1: Interpreting Logo Commands
In
MicroWorlds, every word you type into the command center is interpreted
as a request for the "turtle" to do something.
Part
2: Exploring Line Segments & Polygons
| To
draw a circle using MW:
|
Part
3: Exploring MW Procedures
MW
allows you to create a procedure to execute multiple commands as a single
command. Each MW procedure begins with to and is followed by the
name you assign to the procedure. As to begins each procedure,
end closes each procedure (see example below).
To
enter and run procedures in MW:
- Choose the
Pages pull down menu and click on Procedures.
- Enter your
code on the procedures page. For example, the following code will
create a square of side length 50 turtle steps.
to square
repeat 4[FD 50 rt 90]
end
- Return to page1 by pulling down the Pages menu and
clicking on page1.
- To run the procedure above, type the procedure name (in this case
square) in the command center and strike Enter.
|
You just constructed
two square procedures with different values for the length of the sides.
Instead of re-coding each time, variables can be used in a procedure so
that different values can be substituted into the code.
| To
include a variable in a procedure:
In this example
the colon : denotes the variable named steps.
To square :steps
repeat
4 [FD :steps rt 90]
end
As before this
procedure would be entered on the procedure
page, then executed through the command center on the front page by
typing both the procedure name and the value for the variable steps
(e.g., square 50).
|
Part
4: Two variable code for a regular polygon
| Writing
a procedure with two variables:
This procedure
uses two variables, steps and sides. Steps refers
to the length of the side of a regular polygon and sides refers
to the number of sides of the polygon.
To polygon :steps
:sides
repeat :sides[FD :step rt 360 / :sides]
end
This procedure
would be entered on the procedure page, then executed through the
command center on the front page by typing both the procedure name
and the values for the variables steps and sides with
a single space between the values(e.g., polygon 50 4).
|
| This
procedure uses the variables, steps and angle.
To polygon
:steps :angle
repeat 360 / :angle [FD :steps rt :angle]
end
|
Part
5: Run a Procedure with Buttons and Sliders
MW allows buttons
to be used to execute procedures and sliders to control variable values.
For instance your previous procedure polygon can be made more user-friendly
by creating a button that instructs MW to create a polygon and creating
sliders, named steps and angle to control the values of
these variables.
To
Insert a Button and Slider:
- On the front
page, page1, click on the left-hand side icon resembling
a finger and move your pointer into the turtle space. A hand symbol
will appear on the screen. Click the left mouse button. Label your
button. Once this button is labeled it may be dragged to any screen
location you desire by a right click and hold drag.
- Follow a
similar procedure for your slider. Name the slider the variable
name in your procedure. Change the range of values for the slider
appropriately to your procedure.
- If you have
created a variety of procedures you may use the same slider for
all the buttons you have created or you may create a new slider
for each button.
|
Extensions:
|