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

Changing your mind

Introduction

A procedure you have defined is not fixed. You will want to change one - to make a shape bigger, or fix a number you got wrong - and typing the whole definition again is not the way.

Opening it

ed "star

The screen clears and your procedure appears on it, with a line across the bottom:

 Logo Editor:^C to accept,<ESC> to quit

That is a different kind of screen from the ? prompt. Nothing you type here runs; you are changing text, and it takes effect when you leave.

Note the " before the name. That mark matters and S17 explains it properly; for now, ed wants it.

Give it a moment. The editor takes a second to draw, and for that second you may see the status line with nothing above it.

The four keys you need

The arrow keys do nothing in here. At the ? prompt they type [ and ]; in the editor they do neither that nor anything else. Moving about is done with CONTROL.

Press What it does
CTRL-J Down one line
CTRL-E To the end of the line
CTRL-Y Delete the character before the cursor
CTRL-C Keep the changes and leave

Typing inserts at the cursor. Nothing is ever overwritten, so to replace something you delete it first.

When the editor opens, the cursor is at the end of the first line - after the procedure's name.

There are about twenty more keys. Appendix I has the ones that are worth knowing; these four are enough for most changes.

The code

Type that in, then ss, cs, ht and star to see what it draws - a five-pointed star.

Now change the 144 to 72:

  • ed "star
  • CTRL-J to get to the second line
  • CTRL-E to get to the end of it
  • CTRL-Y four times. That takes off 144] - the closing bracket counts
  • Type 72]
  • CTRL-C

Starting from

A fresh boot, at the ? prompt.

What you should see

While you are in the editor, after the deletes and retyping, the second line reads:

repeat 5 [fd 60 rt 72]

The procedure in the editor with the angle changed to 72

CTRL-C prints star defined and takes you back to ?. Then cs and star draws a pentagon.

The procedure is still called star, and now draws something that is not one. Nothing stops you renaming it - the name is on the first line and you can edit that too.

Change one thing

  • Make the same change again, but press ESC instead of CTRL-C. Run star. Which shape do you get, and what does that tell you about when a change takes effect?
  • Type ed "star and press CTRL-C straight away, without touching anything. What does Dr Logo say, and is it telling the truth?
  • Type ed "wheel, which you have never defined. What appears? What does that suggest about another way to write a procedure from scratch?

When it goes wrong

Symptom Cause
The arrow keys do nothing They do nothing in the editor. Use CTRL-H and CTRL-D to go left and right.
Pressing [ gives you a bracket where you did not want one You are at the ? prompt, not in the editor.
The editor opens with nothing in it but the status line Give it a second to draw.
You get to wheel and end and nothing between That name has no procedure. ed offers you the frame for a new one.
Your change did not take ESC throws changes away. CTRL-C keeps them.
You counted the deletes wrong and the number is odd Delete the rest of it and type the whole number again - the editor always inserts, so half-deleted numbers stay put.

Summary

ed "name opens a procedure for editing. The arrow keys do nothing; CTRL-J and CTRL-E move, CTRL-Y deletes backwards, and typing inserts. CTRL-C keeps the change, ESC throws it away. Appendix I has the rest of the keys.

Next

S11, keeping your work - saving what you have written to the disc, so it is still there tomorrow.

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.