Printing Logo graphics. William A. Beasley.
One of my duties as well as my pleasures is to teach computing to people ranging from elementary schoolers to college professors, I have found Logo an excellent tool, and I continually delight at the inverse relationship of age to learning speed. Like most people using Logo I begin teaching with graphics; therein lies the tale at hand.
Graphics, especially in color, are delightful teaching tools. A problem arises when a student wishes to take the product from the class to show playmates or colleagues. The monitor is not portable, and somehow the listing of a procedure does not carry the same fascination as a picture.
It is possible to acquire a printout of a Logo screen by saving the picture to disk (using enormous quantities of disk space), exiting Logo, loading the picture as a binary file, and dumping the binary file. This is awkward, so I decided that something more user-friendly would be helpful.
The Terrapin Logo documentation provides a simple procedure for dumping Logo screens directly through the Orange Micro Grappler printer card. The procedures shown here constitute an elaboration on that procedure, and serve to assume the burden of remembering specific control codes and sequences. They are functional but not terribly elegant, as my grasp of the language remains a bit shaky (Logo programmers above the age of 12 are hard to find around here, and those of the shorter persuasion are rarely helpful on issues of programming style).
There are three procedures, called in sequence. TO HARDCOPY is the initial procedure accessed when one wishes a screen dump. TEXTSCREEN switches from the graphics page to the text page without destroying the graphics. The 14 lines that follow outline the available options. The PRINT command is used here as it would be in Basic.
The next line assigns to the variable the value that is then entered through the keyboard. REQUEST is the INKEY$ counterpart, and FIRST is used to store the value as a word (the first element of the list REQUEST) rather than a list.
FULLSCREEN returns to the graphics display; no more human input is needed. The last line calls the procedure TO DISCRIMINATE and sends to it the current value of WHICH ("WHICH is the name of the variable; :WHICH is the value. It is like difference in Basic between PRINT "X" and PRINT "X".)
The fact that TO DISCRIMINATE carries in its first line :WHICH indicates that it is expecting a value to be passed in. Actually, "WHICH is a local variable here. Although I kept the same name as used in TO HARDCOPY, it can be called just about anything you please as long as all instances of :WHICH in TO DISCRIMINATE are replaced by :YOURNEWNAME. (I suspect I kept the same name partially because my old Basic habits intrude.) The second line is a simple error trap. The next twelve lines assign values to the variable "SECOND on the basis of the value passed in from TO HARDCOPY. The values assigned are the control commands for the special Grappler functions; WORD is used here to avoid adding spaces between the commands. TO DISCRIMINATE then passes control to TO PRINTER, sending to the new procedure the needed control codes in the form of "SECOND.
There is another local variable in TO PRINTER. In this case I again retained the old name from force of habit, but in fact all instances of :SECOND in TO PRINTER may be replaced by consistent use of :WHATEVERYOUPLEASE.
The next line assigns CTRL-I to the variable "FIRST. CHAR 9 is the Logo equivalent of CHR$(9). Next the value of CTRL-M (carriage return for the Apple) is assigned to the variable THIRD. OUTDEV 1 accesses slot 1, the location of the printer (compare to PR#1).
Then a string of commands is printed out to slot 1; the first is CTRL-I, the second the control codes for the desired special printout features via the Grappler, and the third RETURN. This is the sequence of commands required to activate the Grappler and indeed it seizes control the Grappler and indeed it seizes control at this point, ignoring the keyboard until the screen has been dumped. OUTDEV 0 returns us to the screen.
Actual use is easy even for me. The three procedures are stored on my Logo file disk under the name EUREKA! Logo (it seemed an appropriate end to the debugging). After loading, Logo, I type READ "EUREKA!. The Apple kindly does so, noting the HARDCOPY, DISCRIMINATE, and PRINTER are defined. I then proceed with whatever graphics routines I desired. When I have a screen I wish to dump, I type HARDCOPY and am presented with my options, from which point the computer takes over.
Figure 1 is a sample screen dump (using optin 6) of a program written by one of my shorter colleagues to provide some idea of the results.