Date: Mon, 12 Apr 93 14:57:24 EDT From: swensotc@ss1.sews.wpafb.af.mil (TIMOTHY C. SWENSON) To: ts@chyde.uwasa.fi Subject: qhj13.lis Editor's Forumn Here is the first issue produced from the suburbs of Dayton, Ohio. We are now moved and mostly settled in. For the record here is my new address plus e-mail address: Tim Swenson 5615 Botkins Rd. Huber Heights, OH 45424 (513) 233-2178 swensotc@p2.ams.wpafb.af.mil Next, I would like to apologize to the e-mail readers of the QHJ. When sending out the last issue, my mailer went south on me. Most people reported getting up to 60-70 copies of the issue. What made the matter worse is that I mailed the issue on a Friday, so that it was not until Monday that I found out that there was a problem. I don't know what went wrong. The mailing list was exactly the same one that I had used for several previous mailings. I will do my best to see that it does not happen again. Again, sorry for the inconvienience. Because of the move, this issue has taken longer than my prefered "an issue every other month." Now that I have a house of my own to take care of, and I plan to start on my Masters sometime soon, I hope that the QHJ does not suffer from lack of my time. I would like to see more articles submitted from readers. I know that many of you are programming out there. How about writing something up and sending it my way? I would especially like to see someone write an article discussing how to go about programming in the Pointer Environment (either in SuperBasic, Assembler, or C). Most users in the US do not use the Pointer Environment, and many do not know of it. As more new items are becoming available for the QL, I have been tempted to include the news of these items in the QHJ. Instead, I have decided that I will avoid making the QHJ a news platform. We already have a number of good sources for new information about the QL with QL World, the International QL Report (about the best source around for new information), and Update magazine, plus the many local user group newsletters. I am focusing on areas concerned with programming. I will cover news of a new language or programming aid, but not of a new card or item for the QL. I will leave this up to the better mediums. Text Editors By Tim Swenson This is a short review of the text editors available for the QL. Editors come in two basic types: moded and mode-less. A moded editor is one that has a command mode and an edit mode. The Unix editor VI is a classic example of a moded editor. All commands are typed in with out any extra keys ( dd deletes a line). Once in the input text mode, you can not move the cursor around, but must first hit ESC to exit the edit mode and enter the command mode (moving the cursor is done using the h, j, k, and l commands. A mode-less editor is one that has only one mode in which regular keys are used to input text and the Control, Alt, or ESC keys, in conjuction with regular keys, are used to enter commands. Most editors and word processors are considered mode-less. ED by Metacomco ED is the text editor that comes with all Metacomco languages. It is fairly powerfull, with a limited macro language. It is a modeless editer, but it does have mode-like features. It has both immediate and extended commands. Hitting F3 brings up a command line. All editing commands can be entered at the command line. The extended commands, like string search, can only be entered at the command line. Obviously you will not be entering cursor movement commands via the command line, but having all commands available from the command line is usefull for creating macros. Many commands can be entered on one command line, and with the repeat command, limited macros can be created. ED also has the feature of allowing the user to designate the shape of the editing window on start up. This allows you to move the editor where you want it and make it as large or small as you like. ED also has a screen redraw feature (as all QL editors should have). ED does not allow editing of mulitple files at one time, but more than one copy of ED can be run. They can be moved and reshaped so not to interfere with each other. With only a 29K executable file size, ED is not a memory hog. QED by Jan Bredenbeek QED is a freeware version of Metacomco's ED. It functions almost exactly like ED. The command set is the same as ED. It does lack the ability to change it's location and shape, but it does add an extra line at the bottom of the screen that shows the cursor location (line and column) and the filename. The only advantage QED has over ED is that it is free. If I lost my copy of ED, I'd have no problem using QED. MicroEMACS ported by Ken Norrie MicroEMACS is a version of EMACS originally written by Daniel Lawrence. MicroEMACS has been ported to many operating systems (MS-DOS, UNIX, Atari) including the QL. MicroEMACS is a fairly complex but very powerfull text editor. MicroEMACS, like EMACS, is really a mode-less editor, but is does have modes. MicroEMACS has modes like: WRAP - allows for automatic word wrap and paragraph reformatting. C - This mode has helps in writing C programs. One feature is help in bracket structure. For those that don't know, the { and } mark the begin and end of a program structure. In C mode, when a } is typed, it's cooresponding { is quickly highlighted. It provides for editing multiple files and a full macro language. It does take a while to get used to MicroEMACS. It is based around the use of buffers. Files are read into a buffer to edit. Deleting areas of text is really putting them into a kill buffer, where they can be brought back to be pasted into another location in the editor. Since MicroEMACS supports editing multiple buffers, it supports editing multiple files. After using MicroEMACS for about two years, I still have not touched the more advanced features. To some people EMACS is almost a religion. There are USENET News readers for EMACS. There is a Unix mail interface for EMACS. Some people use EMACS as a front-end to Unix. There are three versions of MicroEMACS available, version 3.8, 3.9, and 3.11. Each version is an improvement of the previous with new features added. Having used 3.8 and 3.9, with the limited commands that I know, I can't tell the difference. For most text editing, almost any version should do. ELVIS ELVIS is a Freeware version of the Unix editor VI. ELVIS has been written to be portable across many systems. I believe it started on the Atari ST, but has made it to many systems including the QL. Not having used ELVIS, I can only assume the QL version is a straight port and should be just like using VI. As mentioned before, VI is a moded editor. The Editor by Charles Dillon of Digital Precision The Editor is a commerical mode-less text editor. Like ED and QED it has both immediate and extended commands and it has a limited macro ability. Unlike the other editors mentioned so far, The Editor can edit binary files (executables). This allows The Editor to act like a file editor. The Editor has some built in features for printing headers, footers, bold, NLQ, etc. This gives it the advantage of producing good looking listings. The Editor documentation is large and comprehensive, with 142 pages. For one that is used to different editors, this over abundance of documentation can get in the way. At least there are a few pages that summerize the editing commands. Even thought I have a copy of The Editor, I really have not used it, so I can't provide any input on usage. Spy by Ark I've only seen Spy once, so I can't say too much about it. Like The Editor, it can edit both text and binary files. I'm guessing that it is like most QL editors in that it has both immediate and extended commands. Other Editors In looking though the QUANTA and IFE libraries, I have come across a few other editors. I have seen PROGLIST_BAS from the QUANTA library and found it to be very simplistic. Not an editor for constant use. I can't say much for the one's I've found in the IFE library (ASCII-Editor, Editor, Stored Editor, TRA-Tab Editor). If someone knows about these editors maybe they can enlighted us on them. QL Languages By Tim Swenson With some recent ports of AWK and LISP to the QL, I wondered exactly how many languages are available for the QL. I then look thought some older QL World's, an older copy of the QUANTA library, and the IFE library to see what I could find. Below is a list of the languages I found. Commercial packages are marked with a $ after them. Those with a * are available from the QHJ. On the Shareware/ Freeware packages, I've documented where they've come from. SuperBasic Compilers QLiberator ($) Turbo ($) Supercharge ($) C C68 (*) QUBBESoft Small-C (*) QUANTA Metacomco Lattice C ($) Digital Precision C ($) DP C Special Edition ($) Pascal Metacomco Pascal ($) Computer One Pascal ($) Pro Pascal ($) Forth Forth-79 (*) QUANTA e-Forth (*) Digital SuperForth ($) BCPL Metacomco BCPL ($) Fortran Pro Fortran 77 ($) Lisp Metacomco Lisp ($) WS-Lisp (*) QUANTA Xlisp (two versions) IFE Prolog QL-Prolog (*) IFE APL Metacomco APL ($) LOGO Logo (*) IFE AWK GNU AWK (*) Prolog Interpreter A Review by Tim Swenson While looking through the IFE database I found reference to a Proglog Interpreter. Once I got the disk, I found QL Prolog version 1.00 (20 March 1990) by Hans Lub. Before I could review the package, I had to learn a little Proglog. I found a Prolog book at my local used computer bookstore and started reading. Prolog, like Lisp, is an AI language, and they both have various dialects. QL Prolog is based on Edinburgh style as covered in the book "Art of Prolog" by Sterling and Shapiro. The book I bought is based on another dialect of the language. If you are going to use this interpreter, I do recommend getting the right book. Before I get in to QL Proglog, let me first discuss what the language Prolog is like. Prolog can best be described as a language based on a database of facts and rules. Facts attribute properties to items. Like "Bob is a Man". Rules define conclusions based on certain facts, like "if a man then mortal". Once a database is created, then queries can be made on the database to answer questions. The language can do more than this, but this is the philosophy of the language. QL Proglog was designed to be a learning tool for Prolog. Usually this means that it has minimal looks and error checking. QL Prolog goes beyond the minimal. It has one window for the interpreter and one for error messages. Unfortunatelly there is no way to make the interpreter full screen. QL Prolog even comes with a few QL specific commands to handle the screen. An included help file documents all of the command implemented. QL Prolog comes with a few example program including a version of Eliza. When running Eliza, I found QL Prolog to be a bit slow. The documentation does mention that optimization was not added to the program. Don't expect any of your programs to execute with blinding speed. Since this version was written three years ago, there could be a more recent version available. If the author has not moved, the source code should still be available for `10 ( C and Assembly). Once I find a library that carries the right book, I can explore the interpreter further. QL Prolog does a fine job of making Prolog reachable to QL programmers. I don't see Prolog as a language for all, but QL Prolog could be used to get you started if you need Prolog for work or school. eFORTH Interpreter A Review by Tim Swenson While on the subject of languages, I thought I would finally take a look at a program that I had recieved a while back. Salvador Merina of Spain has ported eFORTH to the QL. eFORTH is a portable implementation of a FORTH interpreter. The main version of eFORTH is the MS-DOS implementation. Not being a FORTH programmer, I can only provide a cursory look at the program. eFORTH is written in Assembly and comes with the complete source code. It loads by RESPRing some memory and loading a _bin file into memory and the making a CALL to it. I have tried to run eFORTH with ToolKit II loaded in memory, but eFORTH locks up the machine. The boot program does a PEEK to find how much memory is available and then RESPRs it all. I have part of ToolKit in my disk drive ROM so it may not be a clash with the ToolKit commands but more of a memory conflict. eFORTH comes with a short Quill file that tells you how to start eFORTH and run a few simple FORTH commands. It does not document how to exit eFORTH. It also documents the QDOS specific commands of eFORTH. In a glossary file is the description of all of the eFORTH commands. There is not beginner documentation. It is assumed that the user already knows FORTH. Since eFORTH seems to implement FORTH-83, I found the book "Starting FORTH" by Leo Brodie to be very usefull. With a local Sinclair FORTH SIG in the area, I might start getting into the language. The documentation explains that you only have 16K for program space, but shows how to get 1.8 Meg of program space with a Gold Card. It does not mention lower memory QL's, but there might be a way to free up more memory. With a 12K executable, I can only assume that most of memory is taken up with stack space. eFORTH does not come with any example programs. So you can't really give it a good "test drive" once you get it, unless you know FORTH. Once eFORTH is running, you will see a white screen with a green border and black letters. The program name an version number is displayed and a blinking cursor is ready for you to enter FORTH commands. In trying out a few sample commands that I found in the Brodie book, I noticed that eFORTH is not blindingly fast. Even on simple commands there is a pause while eFORTH works on the problem. It's hard to say if the assembly code was optimized for the QL. Overall, eFORTH looks to be a full implementation of the FORTH-83 language. It has a few quirks that will cause frustration to some QL users from integrating into their environment, but they should not stop any FORTH enthusiasts. Programmer's Bookshelf Revisited By David Nash [ David Nash (dnash@chaos.demon.co.uk) responds to a past article on books that most programmer's should have. - ED ] I fully agree with your bookshelf - I have recommended almost all the books in your general and language lists ( I have read 'Elements' but have not seen it in a bookshop. I don't have the Knuth books - yet!). BTW, 'The Mythical Man-Month' is by Fredrick P. Brooks Jr. ISBN 0 201 00650 2, reprinted with corrections, Jan 1992 by Addison Wesley. I would add the following to the list, they are all important texts on my bookshelf: BCPL the language and it's compiler, Martin Richards & Colin Whitby-Strevens ISBN 0 521 28681 6 Cambridge University Press. This is THE book on BCPL, and very good too. It presents the full source of the BCPL lexical and syntax analyser so it will interest anyone interested in compilers. BCPL was the first compiler available for the QL. The Psychology of Computer Programming, Gerald M. Weinberg ISBN 0 442 20764 6 Van Nostrand Reinhold. Very interesting insights on programming and programmers. C A Reference Manual - 3rd edition, Samuel P. Harbison and Guy L. Steele Jr. ISBN 0 13 110933 2 Prentice Hall. Thi is the best reference I know of for both K&R and ANSI C, It lives on my bookshelf beside the two K&R editions. C Traps and Pitfalls, Andrew Koenig ISBN 0 201 17928 8 Addison Wesley. A discussion of the 'traps & pitfalls' of C and how to aviod them. The text was developed from an internal Bell Labs paper which was requested by over 2000 people. The Standard C Library, P.J. Plauger ISBN 0 13 131509 9 Prentice Hall. This book presents the complete source code for an ANSI C Library with a lot of discussion of implementation issues. The Whole Internet Users Guide and Catalog, Ed Krol ISBN 1 56592 025 2 O'Reilly & Associates. What the Internet is and how to use it from Telnet to the World Wide Web. This book is currently hard to find in the UK - demand exceeds supply. Operating Systems Design and Implementation, Andrew S. Tanenbaum ISBN 0 13 637331 3 Prentice Hall. The MINIX book. A good general discussion on operating system design and the source code to MINIX. Computer Networks, Andrew S. Tanenbaum ISBN 0 13 166836 6 Prentice Hall. A complete introduction to computer networking, with examples drawn from all the major networking systems. And finally for fun: The New Hackers Dictionary, Eric Raymond ISBN 0 262 68069 6 MIT Press. The hard copy form of the Jargon File - defines the slang and jargon of the computer world. Contains the correct version of some of the stories found in other books like the Devouring Fungus. The Jargon File is actively maintained vi the Internet and the electronic file is more up-to-date than the book. Lists like that make you realize how many important books you have. Recent Ports By Tim Swenson MausNet has brought news of a few recent ports to the QL. Below are the details: CRON - Elik Slagter has written a version of Cron, the Unix Execute-at-a-certain-time program. Cron is a process that runs in the background and will execute a particular program at a described time. The crontab file tells Cron what program to execute and when to do it. The complete source code has been posted to MausNet and may be available at some archive site. GNU-Awk - Dirk Steinkopf has ported GNU Awk 2.14 to the QL. The port does not fully work due to some bugs still in the C68 library but Dirk says that 99% of the functions of AWK work and are usable. Dirk did not mention the availablity of the program. XLISP - Richard Zidlicky has ported XLISP21D (XLISP Plus) to the QL. "It is nearyly Common Lisp (complex and ratio nums, squence fn's, defstruct, format, defvar, defconstant, image save/restore..). I have implemented pretty good QDOS support (breaks, line editing, graphics, textpos'ing and stackchecking). It compiles with C68 v2.05 or 3.05. The _exe is about 173K big with a few options turned off, so 640K is the absolute minimum (for compiling a Trumpcard is the minimum), the speed is quite acceptable." Once unpacked, the package takes 1 disk for the exacutables, 1 disk for source code and 1 disk for the documentation. Richard has put the source code and executable on sabrina.unipd.dei.it so it is available via Anon-FTP. I have down loaded a copy, but the executable has lost it's header information so the QL returns "bad parameter" when I try to execute it. I don't have enough memory to do a recompile. If anybody has the executable, can they HAR it and put it on sabrina, or send it to me on disk? Byte Input in SuperBasic By Peter Sulzer [ In the last QHJ, I mentioned that I could not get single byte input to work in SuperBasic for my QL to Z88 program. Peter Sulzer kindly wrote back and proved that I was wrong. Below is a short routine Peter sent that shows how standard SuperBasic can do byte input. - ED] 100 OPEN_IN #4,'source':OPEN_NEW #5,'destination' 110 REPeat copy 120 IF NOT EOF(#4): a$=INKEY(#4,-1):ELSE EXIT copy 130 PRINT #5,a$; 140 END REPeat copy 150 CLOSE #4: CLOSE #5 With Turbo this is real fast, of course QLiberator is a bit slow for such "complicated" tasks. Of course you won't reach the speed of the C function getc(fp) as C uses a buffer and must not access QDOS' IO.FBYTE function for every byte - even an assembler prog using IO.FBYTE for every byte is most probably slower than a C prog using getc(fp)! FORTH Programming by Gary M. Ganger Chairman, Timex/Sinclair Users Group Chairman, Forth Interest Group Dayton Microcomputer Association I have been programming with FORTH for a number of years now and have used it on the 1802, PDP-11, 6502, 8080, Z-80, 68000, 8086, V-20, 80286, and the 68HC11 CPU's. The different CPUs have many different assembly languages and when writing programs that you want to run on all the machines you can have a nightmare of problems. BASIC and C are languages that have been used among many programmers, but they require large machines with conversion routines to make it work on each CPU. FORTH has been written for each CPU and can be run fully in 8 to 16K on any CPU. If you write a FORTH program on one CPU then it will run on any other CPU if it is the same version of FORTH. Most programmers have difficulties with understanding FORTH. When Charles Moore first wrote FORTH it was in answer to his Professors at MIT who said you can't do that. It is easier for a programmer who understands assembly code to use FORTH than any other language. FORTH is a threaded language, building new words on a basic set of primitive words written for each CPU. A baseline FORTH is set up to act like a CPU attached to a dumb terminal. As each machine has added color graphics and sound, different new words are added to take advantage of all the features. When writing programs for other CPUs, the additional features must not be used or the programs will not work. Each version of FORTH has an EDITOR and Assembler to allow faster programs to be written and stored for future use. Like BASIC a FORTH program can be run as it is written, to check operation. After a program is checked it is written to a screen and stored for future use. By loading the screens, new words are added to the dictionary when needed. As words are used, they can be removed and the space used for new words. After a complete routine has been developed, the meta-compiler can remove all unneeded words and a compact program can be put in ROM and added to a stand-alone CPU for a final product. Some of those products are used in robotics, HOBART scales, badge readers, microwave controllers, ATARI games, micro-controllers, data base software, graphics software, and CPU internal code. The FORTH teaching guide that is most used is the book by Leo Brodie, "STARTING FORTH". This book explains the basic words that are common to all FORTH versions. It has cartoons that show the operation of each word in a way that even children can understand. It also makes it easier to remember how each word is used as you are programming. Leo also wrote a newer book "MASTERING FORTH" to give you examples of programs you can try. This is a few of the reasons that FORTH is used. Many say either you hate it or you love it. I use it as part of my programming needs. I like many of the built-in features but sometimes it is harder to explain my programs to others that write in other languages. I have included some sample programs that I have found fun and useful. I hope you like them. The QL has several FORTH compilers available, some in the public domain. I try to give FORTH demonstrations each year at COMPUTERFEST in Dayton each August. If you want to see them, see me at the COMPUTERFEST museum this year, 28 and 29 August at Hara Arena. The following is an example of a FORTH program. It converts a DEC PDP-11 RAD50 word to ASCII characters. It is written in F83. OCTAL VARIABLE RAD VARIABLE CH1 VARIABLE CH2 VARIABLE CH3 : CH1! 0 RAD @ 3100 MU/MOD CH1 ! 2DROP ; : CH2! CH1 @ 3100 * RAD @ SWAP - DUP 50 / CH2 ! ; : CH3! CH2 @ 50 * - CH3 ! ; : ANSWER RAD ! RAD @ U. CH1! CH2! CH3! CH1 ? CH2 ? CH3 ? ; : ANS DUP 0= IF SPACE DROP ELSE DUP 33 < IF 100 + EMIT ELSE DUP 33 = IF 44 EMIT DROP ELSE DUP 34 = IF 56 EMIT DROP ELSE DUP 35 = IF ." spec" DROP ELSE 22 + EMIT THEN THEN THEN THEN THEN ; : READ CR ANSWER CH1 @ ANS CH2 @ ANS CH3 @ ANS ; To use enter RAD50 number READ to print conversion. Such as: 174777 READ Answer: 174777 47 47 47 999 / Set octal variables for rad, ch1, ch2, and ch3. / ch1! stores octal value in ch1. / ch2! stores octal value in ch2. / ch3! stores octal value in ch3. / answer stores rad50 in rad and breaks out each octal value. / ans converts values to ascii characters. / read takes top of stack and prints rad50 values and characters. Programs to convert Celsius to Fahrenheit to Kelvin to Rankine: : C>F 18 10 */ 32 + ; : F>C 32 - 10 18 */ ; : K>C 273 - ; : C>K 273 + ; : F>K F>C C>K ; : K>F K>C C>F ; : F>R 460 - ; : R>F 460 + ; : C>R C>F F>R ; : R>C R>F F>C ; Program to print a POEM on the screen. : POEM CR 11 1 DO I . ." little " I 3 MOD O= IF ." Indians" CR THEN LOOP ." Indian boys. " CR ;