1

My son and I are playing around with LOGO programming. It's great to see that there's a package already available for pi with apt-get install ucblogo.

However, in ucblogo arrow keys output a sequence of characters at the prompt, rather than moving through the text.

I don't have the pi in front of me, but I think it was something like ^[[A for left-arrow. (The letters were A B C and D, I think.)

Is this a problem with LXTerminal or ucblogo? The arrow keys work fine in nano, so I'm guessing it's logo.

Is there a way I can fix this without recompiling?

I did try compiling the latest (6.0) source from https://www.cs.berkeley.edu/~bh/logo.html, but ran into a few roadblocks. Pi's version is 5.5.

2
  • I apparently don't have enough reputation to tag this with logo or ucblogo. Would those be good tags to add? If so, can someone please add them? Jul 21, 2015 at 19:10
  • 2
    I would not worry about the tags since they are mainly useful when there are multiple questions using that tag; since there don't seem to be any similar questions this would seem to add little value or improve the chance of receiving an answer. Jul 21, 2015 at 19:57

2 Answers 2

3

Is this a problem with LXTerminal or ucblogo?

The latter. Programs such as this have to implement their own keycode handling. When they don't do this for special keys such as the arrows, they are prone to just display them as a sequence of characters derived from the keycode. That's what you are seeing.

Keep in mind this is a pretty obscure thing which fell into maintenance limbo 7 years ago. That doesn't mean it doesn't work, it just means no one was interested enough to continue development to deal with these kinds of issues.

You could try asking about alternatives, or the state of v6.0 (kind of odd Raspbian/Debian is still on v5.5) on our larger sibling site Unix & Linux -- Raspbian is more-or-less Debian, a long running GNU/Linux distribution, re-compiled for the pi. However, I think you are most likely out of luck here.

1
2

I think what you really want is just to be able to edit your Logo programs conveniently. You can use the edit or ed commands to invoke a text editor, which is, in my opinion, far better than the line based command interface could be, even if arrow keys worked properly. By default, UCBLogo will try to use Emacs, and if you don't have Emacs installed, saying ed will just give you an error message

File system error: Could not read editor file

I think the error actually means that Logo could not find the text file that the editor it tried to launch was supposed to produce. Which was due to the editor not being installed in the system in the first place.

To get editing working, you can either a) install Emacs, or b) use another editor like Nano

Install Emacs

Give this command in a command shell

sudo apt-get install emacs

(I'm not taking sides, but some people don't like Emacs. Others love it.)

...or use another editor like Nano

Give this command after starting UCBLogo

seteditor "nano

Using a text editor like this is quite nice. You give the ed command to enter the editor, and when you exit the editor, e.g. in Nano by pressing Ctrl-X and Y (to exit and save), UCBLogo automatically runs your program.

UCBLogo will tell the text editor (e.g. Emacs or Nano) to edit a temporary file, for example /tmp/logo23322. If you type ed again, you'll get the same file, so you make changes to your program, and again after you save and exit the editor, your changed program will be run immediately.

To save your program permanently, use the save command, e.g.

save "myprogram.lg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.