Dr Logo for the Tatung Einstein, showing a rosette drawn by the turtle
← Back to Courses
module
8

Running off the edge

Introduction

The drawing area is 256 steps across and 192 down, and the turtle starts in the middle of it. That gives you about 128 steps to the left or right and about 95 up before you are asking for somewhere that is not there.

Sooner or later you will, usually by accident. It is worth knowing what happens, because the answer is quiet rather than loud.

Off the edge, by default

Nothing is announced. The turtle keeps going, and the part of the line that would be off the screen simply does not appear. When it comes back on screen, so does the line.

That is why a shape can come out looking like a completely different shape: the instructions all ran, the drawing is just missing the parts that were not on the screen to draw.

Asking for something else

Two instructions change that, and neither takes a number.

fence puts a fence round the screen. The turtle is not allowed out, and a move that would take it out is refused before it happens:

Turtle out of bounds

Nothing is drawn at all - not even the part that would have fitted.

wrap does the opposite. The turtle leaves one side of the screen and comes back on the other, still drawing, like a character in an old arcade game.

window puts you back to the quiet behaviour you started with.

All three stay set until you change them, and cs does not reset them.

The code

Starting from

A fresh boot, at the ? prompt. If you have been experimenting with fence or wrap, type window first.

What you should see

Six sides of 150 steps at 60 degrees is a hexagon, and a hexagon is not what appears. You get a vertical line and one long diagonal, and nothing else - the other four sides were drawn somewhere off the screen.

A hexagon with only two of its sides on screen

Nothing went wrong, and nothing said anything. Every instruction ran exactly as written.

Change one thing

  • Put wrap on a line of its own before the repeat. The same six sides are drawn. How many of them can you see now, and where did the rest turn up?
  • Put fence there instead. Compare what you get with the picture above - the difference is not just that it complains. How much of the shape gets drawn before it stops?
  • Leave the mode alone and change fd 150 to fd 60. Now count the sides. What does that tell you about whether the first version was really drawing a hexagon?

When it goes wrong

Symptom Cause
A shape comes out with sides missing It is bigger than the screen. Nothing is wrong with your instructions - the rest was drawn off-screen.
Turtle out of bounds fence is in force from earlier. window turns it off.
A line appears on the far side of the screen from where you expected wrap is in force. window turns it off.
A drawing that worked yesterday is now cut off Something moved the turtle away from the middle before you started. cs puts it back.

Summary

By default the turtle may walk off the screen and the missing part of the line simply is not drawn, with no complaint. fence refuses the move and says Turtle out of bounds; wrap brings the turtle back on the opposite side; window restores the quiet behaviour.

Next

S9, teaching it a new word - giving a name to a drawing so you can ask for it by name instead of typing it out again.

Get the Newsletter

New guides, disk images and community finds, roughly once a quarter. No spam, we promise, this isn't Tatung's marketing department.
Your subscription could not be saved. Please try again.
Your subscription has been successful.

Newsletter

Subscribe to our newsletter and stay updated.