Creating New Commands
MAKE PONS TO END OUTPUT EDIT POTS POALL
This section shows you how to create new variables, write procedures to make new commands, and see what you have created.
MAKE word word-or-list
MAKE
is the command to use to store information, whether it be a word or list.
Think of a box with a label on it. The label is the name of the variable. The contents of the box is the value of the variable.
To create a box with a label, use MAKE
with a quoted word, like this:
MAKE "NAME "PETER
The label on the box is NAME
. That is the name of the variable.
Inside the box is a value. Right now, it is PETER
, but you can change that value.
It is called a variable because the contents of the box can vary!
You could just as easily type:
MAKE "NAME "LISA
To refer to the variable, use “dots”, as in :NAME
.
:NAME
Result: PETER
PRINT :NAME
PETER
» Things to Try
Create different variables and then look at their value using the dotted version of the word you chose.
A variable name must be a word, with no spaces. It can be upper or lower case.
PONS
PONS
lists all the variables you have created using the MAKE
command.
Type PONS
in the Listener window. Your variables will be listed below.
PONS
MAKE "FLAVOR [CHOCOLATE CHIP]
MAKE "YEAR 2025
MAKE "DATE [JANUARY 31, 2025]
» Things to Try
Create some variables and use PONS
to see their names and values.
TO
You will use TO
in the Editor panel to create procedures.
A procedure is a like a Logo command, except that you invent a new one.
Your procedure can perform any action you want, including reporting information using OUTPUT
.
To make a new procedure called SQUARE
, for examplem, type:
TO SQUARE
in the Listener panel. TO SQUARE
appears in the Editor panel, followed by a blank line, and then the END
command. A procedure needs END
to complete it. END
separates multiple procedures that are in the editor.
If you type TO SQUARE
and there is already something in Editor panel, you will be asked if want to erase the contents. Click Yes to erase everything in the Editor panel or No to keep it there. You can save the contents of the Editor panel at any time using the Save button, or choose Save from the File menu and select the option to save the Editor contents.
Now, after TO SQUARE
, write the commands you want for the square.
When you are done, your Editor panel might look like this:
TO SQUARE
REPEAT 4 [FD 150 RT 90]
END
To create the procedure so you can use it, click the Run button.
In the Listener panel, you will see: SQUARE defined
.
Now you can type SQUARE
to draw a square anytime you want.
Wouldn’t it be handy if the same SQUARE
procedure could draw a square of any size you want?
You can give FD
an input to move the turtle forward any amount. You can do the same thing with a square.
Click in the Editor panel and change your SQUARE
procedure so that it looks like this:
TO SQUARE :SIZE
REPEAT 4 [FD :SIZE RT 90]
END
Click the Run button. In the Listener panel, you will see SQUARE redefined
.
Now try out the square.
SQUARE 100
SQUARE 200
SQUARE 5
When you use the SQUARE
procedure, you need to give it a number for how long each side is. The angle doesn’t change. It still needs to be 90 degrees.
If you type just SQUARE
, you will see this message:
Error: SQUARE needs more inputs
If you want to write a procedure that reports information, see OUTPUT
below.
» Things to Try
Try writing procedures to draw different shapes and designs.
END
END
marks the end of a procedure in the Editor panel.
If you have any errors in your procedure, such as mismatched brackets or parentheses, Logo will tell you. (It won’t tell you if there is an error in your thinking, though. It just checks the syntax of your code.)
If you forget to include END
at the bottom of your procedure, Logo will tell you.
» Things to Try
Try writing more procedures to perform different actions.
Try making some errors on purpose to see what Logo tells you.
Note that the lines in the Editor panel are numbered, and Logo will tell you which line the error is in, which is very handy!
OUTPUT
OP
OUTPUT
allows you to create a procedure that reports information back to you.
TO CONVERT.TEMP :FAHRENHEIT
OUTPUT (:FAHRENHEIT - 32) * 5/9
END
After you define this procedure, you can use it like this:
CONVERT.TEMP 212
Result: 100
CONVERT.TEMP 32
Result: 0
CONVERT.TEMP 78
Result: 25.56
You can use the value that the procedure outputs in a procedure you write.
TO TEMP
PRINT [WHAT IS THE CURRENT TEMPERATURE?]
PRINT (SENTENCE [THAT IS] CONVERT.TEMP READWORD [IN CELSIUS.])
END
Define the procedure and type TEMP
.
WHAT IS THE CURRENT TEMPERATURE?
; the procedure asks you to type a number
72
THAT IS 22.22 IN CELSIUS.
Note that OUTPUT
stops the current procedure from running any further instructions. If the procedure that outputs a result is a subprocedure, Logo continues running commands in the main procedure.
The main procedure is the name of the one you type to start you program.
Subprocedures are procedures that the main procedure runs.
In the example above, TEMP
is the main procedure.
CONVERT.TEMP
is a subprocedure that reports back to TEMP
.
» Things to Try
Try writing procedures that report information. You could report a word (which includes numbers) or a list.
Write a main procedure that calls one or more subprocedures.
POTS
POTS
tells you the names of procedures that you have written that are in Logo’s memory. After creating some procedures in the Editor panel, type POTS
in the Listener panel to see their names.
If you restart Logo, your procedures will be erased, though hopefully you have saved them before restarting Logo.
» Things to Try
Define some new procedures and use POTS
to list them in the Listener panel.
POALL
POALL
shows you everything that is in the Logo workspace, which is its memory. This includes variables, procedures, and some properties. Type POALL
in the Listener panel, which is where the information will be listed.
POALL
MAKE "PETS [DOG CAT BIRD [GUINEA PIG]]
MAKE "FLAVOR [CHOCOLATE CHIP]
MAKE "YEAR 2025
MAKE "DATE [JANUARY 31, 2025]
MAKE "TODAY [JANUARY 31]
PPROPS "PREFS [ARRAYBASE 0 AUTOSAVE OFF CASE TRUE COLORED.TURTLES TRUE DEBUGGER TRUE FONT [MONOSPACE 12 0] CONTROLS.FONT [HELVETICA 12 0] TURTLE.FONT [HELVETICA 12 0] LISTENER.LINES 100 LISTENER.READONLY FALSE PICTURE.FORMAT PNG LOCALE EN PRECISION 2 PRINT.BITMAPS TRUE RELAXED.SYNTAX FALSE STACKSIZE 1000 TAB 4]
The PPROPS
line is information that Logo knows about that are defined as properties. This information is what is contained in the Tools>Settings...
area, where you can easily change them. You can read more about properties here: Property Lists
» Things to Try
After you have used Logo for a while and created variables and procedures, check out what POALL
tells you!