Terrapin Resources

Terrapin Logo 4 has been discontinued! Our new Terrapin Logo version is much more powerful and modern; we strongly recommend that you update to our latest release of the Logo programming language.

Tips and Tools for Logo Programming

Click below for tips on using different aspects of Terrapin Logo and tools you can incorporate to emphasize various aspects of Logo. If you have a question about Terrapin Logo that could result in a tip that would help others or a suggestion for a useful tool, let us know. The tip or tool could soon appear on this page! Also check the Logo Library for useful and entertaining programming examples.

The turtle and its environment

The properties of a Logo turtle, such as pen state, heading, and visibility are well known. A turtle also knows aspects of its environment which may be incorporated into Logo procedures. The Logo Graphics window is a plane defined by cartesian coordinates. GETX provides the turtle’s current X position on the plane and GETY provides the turtle’s current Y position. GETXY provides both the X and Y coordinates in a two-element list.

DOTCOLOR with a two-element list as input returns the color of the specified coordinate on the Graphics screen. DOTCOLOR GETXY or alternatively (DOTCOLOR) returns the color under the first active turtle.

These commands may be used to incorporate “turtle intelligence” into your procedures. The turtle may be used to map the graphics screen or to respond to encountering different colors as it moves.

Does Logo really know what time it is?

Most computers have built in clocks and Logo has access to both the time and the date available from the computer’s clock. The Logo TIME command and the DATE command output the current time and date respectively taken from the computer’s clock in three element lists [hour minute second] and [day month year]. Information from these commands may be incorporated in Logo programs such as the clock programs on our Logo Projects and Examples page. The time may also be used as a random number or random number seed.

Adding comments to Logo procedures

Comments are text remarks in a program that are not executed by the computer, but which provide explanation about what the program does. When writing Logo procedures, it is often useful to add comments to help remember what is intended by a particular Logo command line. In Terrapin Logo, anything that follows a semi-colon (;) up until ENTER, is ignored by the computer. This means that you can add comments to Logo procedures by preceding them with a semi-colon.

Since comments are not part of a Logo procedure, they are removed from it when a procedure is defined into workspace to maximize available memory. To read comments, a Logo file should be loaded into the editor. To preserve comments, save your Logo file from the editor.

A Bigger, Slower, Bolder Turtle

In some circumstances, especially when working with young children, it is useful to have a bigger, slower, bolder turtle so that its movements can be watched step-by-step. Terrapin Logo allows you to easily adjust both the turtle size and the speed at which it moves when executing commands. In addition you can adjust the width of the line that the turtle draws so it makes bolder drawings.

Adjustments to turtle size, speed, and line width can be made via the Turtle Center dialog box or by commands. You can open the Turtle Center by clicking on the Turtle Tool button or by right-clicking (in Windows) or Control-clicking (on the Mac) the turtle itself. The Control Center offers sliders that can be used to adjust the turtle scale and crawl speed and an edit box to enter an integer to represent the line width (in pixels).

Pairs of commands are also available that allow you to manage turtle size, speed, and line width. TURTLESIZE, SPEED, and WIDTH report the current size, speed, and line width of the first active turtle. SETTURTLESIZE, SETSPEED, and SETWIDTH can be used to adjust these attributes. Click on the above commands for more information on using these commands.

Starting over

Sometimes it can be useful to start Logo again and eliminate everything from workspace and return the windows to their default positions. This can be accomplished by choosing Restart Logo… from the Debug menu or by using the RESTART command.

Typing RESTART in the Listener window causes a dialog box to appear asking for confirmation that you want to erase everything and start over. If RESTART is enclosed in parentheses, as in (RESTART), Logo restarts without the confirming dialog box. Use RESTART with care and be sure to save any work you want to keep before starting Logo again.

Printing variables

Within Logo, the contents of lists, which is information in square brackets ([]) is not evaluated. Anything within a list is taken literally so that variable names are treated as text strings rather than the value they represent. If you want to use PRINT or TURTLETEXT with variables, the value of the variable must be extracted before it is put in a list and passed to either PRINT or TURTLETEXT. Both LIST and SENTENCE evaluate their inputs before putting them in a list so are good commands to do this.

For example, if you have a variable named :MY.VARIABLE that contains the number 7 and would like to print it preceded by the words “The value of my variable is” you can use LIST to put the words you want together with your variable and then PRINT the combined list.


Moving the turtle with arrow keys

The Logo turtle responds to movement commands OneKey.LGO utility. This is done with a Logo procedure that waits for input from the keyboard and responds according to what is typed.

While it seems natural to move the turtle with the arrow keys that are now available on all keyboards, arrow keys and other special keys do not output standard ASCII characters for Logo to read. However, Terrapin Logo is capable of understanding such keys on the byte level with the GETBYTE command. A Logo procedure can use GETBYTE to watch for the press of an arrow key and then move the turtle accordingly.

Check out the sample Logo procedure below that moves the turtle with arrow keys to see how this can be done. The up arrow outputs 193, the back arrow outputs 194, the left arrow outputs 195, and the right arrow outputs 196. The sample procedure run recursively and uses GETBYTE to wait for these values when arrow keys are pressed. When the forward or back arrow is pressed, the turtle moves 15 steps in the indicated direction. When the left or right arrow is pressed, the turtle turns 90 degrees in the indicated direction. The Enter key stops the procedure. This procedure can be used as a model and adjusted as desired to map turtle control to the keyboard arrow keys.

Other questions?

  • How do I know which version of Logo I have? The Logo VERSION commands reports the version of Logo that you are currently running along with the date of its compilation. When you have a question or seek help for Terrapin Logo, type the VER command in the Listener window and report the version and date of Terrapin Logo you are using to expedite a response. Terrapin offers an upgrade path for those using earlier versions.
  • Logo 4 is different from Logo 3; how can a program tell the difference? Logo 4 has a new property list “LOGO.ENV. This property list contains a VERSION property, which is a number, like 4 for version 4. Logo 3 does not have this property list, so asking for that property would output an empty list instead of a number.