Bob Hartung, [address omitted]
While the TOOLKIT II (TK2) manual is not exactly a shining example of casual reading material, it does give springboards for ideas on using this powerful extension to QL SuperBasic commands. If you have not already done so, put the scotia-sized manual through an enlarging copier. It’s amazing how much clearer things become when you can read them!
Within the limitations described in section 6.1 of the TK2 manual, the DO function can be used as a powerful user-defined programming extension. The DO file is simply a sequence of commands or a routine that is stored on mdv, disk, or RAMdisk media without numbered program lines. If it is stored in the default drive, by just keying in <DO filename> the command-sequence or routine is activated or “RUN”. It does not alter any listed program that is already in memory.
With TK2 activated, for direct KBD entry of a DO file to a disk in drive 1, the following method may be used for short command-sequences:
OPEN_NEW #5,flp1_filename
PRINT #5,'INPUT "Enter test text ";a$:PRINT a$'
CLOSE #5
Note that the entire PRINT statement must be bracketed by either quotes or apostrophes and as in ALTKEY definition, if any bracketing within the statement uses quotes, then outer apostrophes must be used, or vice versa. Note, too, that a simple FOR loop may be used within a one line multi-statement but not the END FOR type or a REPeat loop. Also, if a DO routine is halted during processing, a NEW may be required before resuming.
Obviously, for longer command-sequences or routines direct entry from the KBD is not practical. Any line-editor such as THE EDITOR or my INFOwriter that does not insert extra control characters may be used to form and store the DO file.
Listing 2 is a routine that may be used to create the required ASCII files. With this, one might do several sets of ALTKEY definitions, for example, that would emulate on the QL the single-stroke keyword entry system or the VAL command many of us wish Uncle Clive had retained. Following the ALTKEY definition in listing 1 is a useful printer-command routine that shows the use of a simple FOR loop in a DO line:
LISTING 1
ALTKEY 'p','PRINT #0;"'
PRINT #0;"Enter command-codes one at a time""EG: 27 52 -1 (-1 to exit)"
FOR n=1 TO 1000:INPUT #0;cc;" ";:IF cc=-1 THEN PRINT #0;"END":n=1001:ELSE OPEN #7,ser1:PRINT #7,CHR$(cc);:CLOSE #7
LISTING 2
100 TK2_EXT
110 FLP_USE flp: REMark Omit & change lines 160 & 330 for mdv.
120 CLS: CLS #0
130 REMark DO file output routine
140 INPUT "DO file title: ";filetitle$
150 INPUT "Save ";(filetitle$);" to drive #";dr$
160 filetitle$="flp" & dr$ & "_" & filetitle$
170 INPUT "Max. no. command-lines: ";cml
180 DIM com$(cml,136)
190 PRINT "Enter line (limit 136 chrs.)""@ to end input & save"
200 FOR n = 0 TO cml
210 INPUT (n+1);" ";com$(n)
220 IF com$(n,1)="@" THEN LET cnt=n-1: GO TO 240
230 END FOR n
240 OPEN_NEW #5,filetitle$
250 FOR n=0 TO cnt
260 PRINT #5,com$(n)
270 END FOR n
280 CLOSE
290 CLS
300 INPUT "Repeat y/n? ";y$
310 IF y$=="y" THEN GO TO 120
320 STOP
330 SAVE flp1_DOfile_DEF
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.