If you’re like me and don’t know machine language, I’ll bet there are times when you really wished you did. You probably would like to make all those fancy application programs with neat advanced features, etcetera. With the power of the QL, you now have an excuse to hold off on learning MC a little longer…Procedures.
Procedures aren’t as mysterious as they may at first seem. In fact, they are rather fascinating, and really deserve some attention, even by novice SuperBASIC programmers. Some pretty neat things can be accomplished with them–things that can only be done in machine code on other computers. Here are a few of the things I have discovered about procedures:
1. Procedures typed in as program lines can be called WITHOUT even first typing RUN!
2. Procedures can be called from within other Procedures.
3. Procedure names can be almost anything, INCLUDING SuperBASIC Keywords!
4. Procedures act just like additional commands added to the QL operating system!
You can discover these things yourself by experimenting and reading the QL Users Guide. The BEST way to learn Procedure structure (and anything else on a microcomputer) is by experimenting. You can’t blow up the QL by typing in the wrong program, although you can get some pretty strange results!
In this article, I will present a practical use of Procedures involving the above mentioned items. I have created a sample program I call JOS (pronounced JOE’s). This program when used will appear to have added and refined some commands to SuperBASIC. To use it, type it in and save it as BOOT. Then put the disk/cart. that contains this program into drive 1 whenever you turn on your QL, so it will load and run automatically. You can even make this the BOOT program on all your disks/carts. If you have I.C.E. you must hold down ALT when you choose monitor (F1) to load the program.
When it first comes on, a screen will say JOS ACTIVE, and a prompt will be waiting for the year. Either continue entering the time and date or hit ENTER at the year prompt. The computer will “jingle” and will instruct you to hit “i”, if you wish to go into I.C.E., or b if you want Basic. If you don’t have I.C.E., you can delete these program lines.
Once you are in Basic, the only way to tell that JOS is there, is by typing LIST. JOS is from line 20000 on. I have placed it this high so it (hopefully) won’t conflict with any other Basic programs. Remember, you can change line numbers with the RENUM command (page 47, Keywords, QLUG). To see a list of all the extra commands available with JOS (so far), just type-in the word “COMMANDS”. The following list will be presented:
LD S D DS CAT LPRINT DEFAULT LRUN LLIST CC L SIREN
Here is what each command does and how to use it:
DEFAULT chooses which drive will be the default for the other commands which require use of a drive. Syntax is DEFAULT “name”, i.e. DEFAULT “MDV1_”. You must add the “_”. You can also specify any other type of storage device.
LD will load a program. Syntax is LD “filename”.
S will save a program. Syntax is S “filename”.
D will delete a file from a storage device. Syntax is D “filename”.
DS will delete a file from a storage device, then save the program in memory as that file. Useful for updating programs. Syntax is DS “filename”.
CAT will give a directory of the default drive.
LPRINT will print text to the printer through serial port 1. Syntax is LPRINT “text”.
LRUN will load and run a program (actually it MERGEs a program with JOS, then runs it). Syntax is LRUN “filename”.
LLIST will send a listing of the program in memory to the printer through port 1. Syntax is just LLIST.
CC will clear windows 0,1 and 2; the whole QL default screen. Syntax is just CC.
L will list the program in memory to window #2. Syntax is just L.
SIREN starts a siren sound. To stop it enter BEEP.
To use the commands, either type them in using their proper form, or use them in a new program. I had attempted to incorporate a NEW command, which would delete everything but the JOS program, but I kept getting an error, and the QL would crash. I was trying to use DLINE TO 19000. Can anyone let me know why this won’t work, or how I can get it to work? Sometimes it would…most of the time it wouldn’t.
Play around, experiment, add your own commands. I have included some of the more useful ones, but I’m sure there are plenty more. Maybe you can add a routine to change the paper, ink, and border, or change windows around. Let me know what you come up with.
By examining this program and figuring out how it works, you will begin to get a good understanding of the power of Procedures. I haven’t even started to exploit the full power they have to offer.
There is one feature of Procedures I would like to explain. While writing JOS I discovered for myself (by accident) that strings could be added after procedure names; I had thought only numbers could be passed into procedures. An example of this is:
DEFine PROCedure say (x$)
PRINT x$
END DEFine say
The proper name of this procedure is “say”. If you had this routine running on the QL, and then typed…say “Hello—it worked!” and enter “hello—it worked! will appear in window #1 (the output window, red). That is how I made the Procedures, such as DEFAULT. DEFAULT is the actual procedure name, and you enter a string after it, which contains other information. You must remember the quotes, though! Also, if JOS crashes with an error, just try again…no harm done.
Remember, experimenting and doing is the key to learning. Fool around, try anything. If it doesn’t work, keep trying, or else scrap it and start over! To constantly resave your own altered version of JOS as you work on it, use the DS command. It will allow you to save your current version, while you can continue altering. Remeber to save it as BOOT so it will auto load and run.
Let me know how you came along in your experimentations. If you have any questions or comments, let me know also. Joe Newman, 325 West Jersey Street #2D, Elizabeth, NJ 07202.

JOS
20000 cc:CSIZE 2,1:PRINT " *** JOS ACTIVE ***"
20010 PRINT "©1986 by JOE NEWMAN"
20020 CSIZE 0,0:PRINT "Enter year or ENTER to quit":CSIZE 3,1:INPUT "year (yy) ",year$:IF CODE(year$)<>0 THEN year=year$: INPUT "month",month:INPUT "day",day:INPUT "hour",hr:INPUT "Min.",min:year="19"&year:SDATE year,month,day,hr,min,0
20030 CSIZE 0,0:BEEP 0,1,255,1300,1
20040 drive$="flp1_"
20050 PAUSE 50:BEEP:PRINT "hit > i)ce or b)asic"
20060 ink$=INKEY$:IF ink$="" THEN GO TO 20060
20070 IF ink$="i" THEN ICE:ELSE cc:STOP
20080 DEFine PROCedure cc:CLS#0:CLS#2:CLS:END DEFine cc
20090 DEFine PROCedure l:LIST:END DEFine l
20100 DEFine PROCedure ld (file$)
20110 call$=file$
20120 file_name$=drive$&call$
20130 MERGE file_name$
20140 END DEFine ld
20150 DEFine PROCedure default (driver$)
20160 drive$=driver$
20170 END DEFine default
20180 DEFine PROCedure LRUN (file$)
20190 call$=file$
20200 file_name$=drive$&call$:MERGE file_name$
20210 RUN
20220 END DEFine LRUN
20230 DEFine PROCedure llist
20240 OPEN #100,ser
20250 cc:PRINT "READY PRINTER (hit any key)":PAUSE 40000
20260 cc
20270 LIST #100
20280 CLOSE #100
20290 DEFine PROCedure cat
20300 DIR drive$
20310 END DEFine cat
20320 DEFine PROCedure s (file$)
20330 call$=file$:SAVE drive$&call$
20340 END DEFine s
20350 DEFine PROCedure lprint (printer$)
20360 OPEN #100,ser:PRINT #100,printer$:CLOSE #100
20370 END DEFine lprint
20380 DEFine PROCedure d (file$)
20390 DELETE drive$&file$
20400 END DEFine d
20410 DEFine PROCedure ds (file$)
20420 call$=file$
20430 DELETE drive$&file$
20440 SAVE drive$&file$
20450 END DEFine ds
20460 DEFine PROCedure commands
20465 cc:PRINT "AVAILABLE COMMANDS FOR JOS"
20466 PRINT "--------------------------"
20470 RESTORE 20480:FOR LOOPER=1 TO 12:READ COM$:PRINT COM$:NEXT LOOPER
20480 DATA "LD","S","D","DS","CAT","LPRINT","DEFAULT","LRUN","LLIST","CC","L","SIREN"
20490 END DEFine commands
20500 DEFine PROCedure siren:BEEP 0,1,1300,150,1:END DEFine siren
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.