Bob’s Notebook: Disk Index, Sorting Routines

See all articles from Sinc-Link v7 n3
Author(s): Bob Mitchell
Publication: Sinc-Link
Pub Details: Sinc-Link v7 n3 (Volume 7, Issue 3)
Date: May/June 1989
Pages: 3-4

BOB’S NOTEBOOK

At the club meeting in April, I promised a utility which would allow the data in my disk indexer (see Sinc-Link Nov-Dec 87 p.6) to be printed on the wide printer with eight entries per line in condensed font. Listings 1 and 2 below will do the job. But here are some explanatory notes.

Listing 1 is straight-forward and should present no problems.

Listing 2: Variable <ff> means form feed and controls the ejection of the paper after 55 lines are printed. You may wish to alter this parameter to some other number of lines. Variable <lf> means line feed and is used to insert a line feed after eight records are printed.

In line 3001, the address 37825 equals 37799 + 26 so as to skip over the first two d$ items which contain the <SEARCH IS COMPLETED> message. The address 37799 is contingent upon your compilation coming up with 37797 as the start of the data area for d$ in the compilation. If it is any other value, you will have to adjust the 37825 & 56024 addresses accordingly.

Line 3007 inserts a space after each file name to separate it from the disk number; similarly, line 3017 inserts two spaces between records. Line 3010 skips over the asterisks in the d$ array; line 3012 stops action and returns to the loader at line 1100 when it encounters a space in the second place in the file name.

LISTING 1

1000 CLEAR 29000: RANDOMIZE USR 100: LOAD "indxLP.Cc"CODE 63000
1010 RANDOMIZE USR VAL "100": OPEN #VAL "4","dd"
1012 PRINT #VAL "4": OPEN #VAL "3","lp"
1015 PRINT #VAL "4": POKE VAL "16090",VAL "135": PRINT #VAL "4": POKE VAL "16094",VAL "8": LPRINT
1017 OUT 127,15
1018 GO SUB 1200
1020 RANDOMIZE USR 63000
1100 STOP
1200 INPUT "what index file? enter full name of file...'' LINE l$
1210 RANDOMIZE USR 100: LOAD l$CODE
1220 RETURN
1900 STOP
2000 RANDOMIZE USR VAL "100": SAVE "indxLP.Bb" LINE VAL "1000"

LISTING 2

  60 REM ! LPRINT
70 REM ! LIST
80 REM !INT +lf,a,b,c,ff
90 REM !USR 63000
1000 RANDOMIZE USR 100: OPEN #3,"lp"
1010 RANDOMIZE USR 100: POKE 16090,135
1020 RANDOMIZE USR 100: POKE 16094,8
1030 OUT 127,15: LPRINT
2000 REM ! OPEN #
3000 LET lf=NOT PI: LET ff=NOT PI: LPRINT
3001 FOR a=37825 TO 56024 STEP 13
3002 IF lf=8 THEN LPRINT : LET ff=ff+1: LET lf=NOT PI
3003 IF ff=55 THEN OUT 127,12: LET ff=0: LPRINT : GO TO 3030
3005 FOR b=1 TO 13
3007 IF b=10 THEN LPRINT " ";
3010 LPRINT CHR$ PEEK (a+b) AND PEEK (a+b)<>42;
3012 IF PEEK (a+1)=32 THEN LPRINT : STOP
3015 NEXT b
3017 LPRINT " ";
3018 LET lf=lf+1
3030 NEXT a

In the Jan-Feb 1989 issue, I provided a utility which would allow the sorting of lists (of information) entered into the Tasword. As I explained before, such lists can be birthdays and anniversaries, things to do, disk names & numbers, anything you like as long as the entries do not exceed 64 characters in length.

In listing 3 and 4 below, you will find a similar utility for doing the same thing with MSCRIPT. Listing 3 is the loader and remains in BASIC, while listing 4 is best compiled using Timachine. Here are some notes on these two programs.

If you don’t have the taswide utility, you should leave out line 98 in listing 3 and make line 240 in listing 4 read: <CLS: BEEP oa, VAL “10”: FOR i=n TO s-1: PRINT d$(i): NEXT i>.

In line 510 in listing 3, the PEEKs get the value of variable <b> in the compiled code <mssort.Cc>; <b> is the length of code to be saved. If you get a different location for variable <b> when you do your compilation, you should change these PEEK addresses accordingly. In line 100, I put the words <MSCRIPT SORT> in inverse characters and followed these with 24 spaces. I also put the words <BLOCK SAVE> in inverse characters in line 120 of listing 4.

Lines 94 and 530 are set up to return action to my Ramdisk; you may change these to go back to the current menu in your disk drive by changing <GO TO 4> to the drive number of your choice.

LISTING 3

  90 CLS : PRINT "MSCRIPT SORT by Bob Mitchell."''"Prior to using this utility, SAVE the BLOCK to be sorted, using the Mscript block markers."
91 PRINT ''"Calculate the length between the block markers and have this at hand."
92 PRINT ''"This utility will sort up to 200 lines with max length of 64 chars. Each line must end with a line feed (code 13)."
93 INPUT "1=cont. 0=menu ";cm
94 IF NOT cm THEN PRINT #4: GO TO 4: PRINT #4: NEW
97 PRINT #VAL "4": LOAD "mssort.Cc"CODE
98 PRINT #VAL "4": LOAD "taswi.Cx"CODE
100 PAPER SGN PI: BORDER SGN PI: INK VAL "9": CLS : INPUT "MSCRIPT SORT (put 24 spaces here) BLOCK SAVE file name? (max 6) ", LINE n$
105 INPUT "drive? (0-3) ";drv: PRINT #4: GO TO drv
110 PRINT #4: LOAD n$+".CT"CODE 47050
120 RANDOMIZE USR VAL "29000"
500 CLS : BEEP SGN PI,VAL "10": INPUT "name for save? max 6 "; LINE s$
510 PRINT #4: SAVE s$+".CT"CODE 47050,PEEK 30896+256*PEEK 30897
520 CLS : PRINT "BLOCK saved; now load MSCRIPT and LOAD relevant file. Delete old BLOCK; use <ADD> to LOAD new BLOCK.": STOP
530 PRINT #NOT PI;"Press a key for menu.": PAUSE NOT PI: PRINT #VAL "4": GO TO VAL "4": PRINT #VAL "4": NEW
550 CLEAR : PRINT #4: SAVE "mssort.Bb" LINE VAL "570"
560 STOP
570 RANDOMIZE USR VAL "100": OPEN #VAL "4","dd"
580 GO TO VAL "90"

LISTING 4

  50 REM ! LIST
60 REM ! LPRINT
70 REM !LEN h$<=66
80 REM !INT +b,oa,ob,sf,a,n,i,j,s,ss,t
90 REM !USR 29000
100 REM ! OPEN #
120 INPUT "length of BLOCK SAVE? <=12800"'b
130 PRINT "Storing CODE in ARRAY"'' FLASH 1;"stand-by..."
140 DIM d$(200,64)
145 LET oa=1: LET ob=2: LET sf=64: LET a=47050
150 LET s=oa
160 LET n=s
170 FOR i=a+1 TO a+b
180 FOR j=1 TO 63
190 LET d$(s,j)=CHR$ PEEK i
195 IF PEEK i=13 THEN GO TO 210
196 IF i=a+b THEN LET e=s-1: GO TO 240
197 LET i=i+oa
200 NEXT j
210 LET s=s+oa
220 NEXT i
240 CLS : BEEP oa,VAL "10": RANDOMIZE USR 64300: FOR i=n TO s-1 : PRINT CHR$ 3;d$(i): NEXT i
250 INPUT "1=sort 0=save? ";ss: IF NOT ss THEN GO TO VAL "440"
255 INPUT "sort on which col.? (1-63) ";t
260 CLS : PRINT "sorting on col. ";t'' FLASH 1;"stand-by...": GO SUB VAL "300": GO TO VAL "240"
290 REM shell-faulk sort
300 LET sn=e
310 LET sn=INT (sn/ob)
320 IF sn<oa THEN CLS : RETURN
330 IF sn/ob=INT (sn/ob) THEN LET sn=sn+oa
340 FOR i=n TO e-sn
350 LET mm=i
360 IF d$(mm,t TO )<=d$(mm+sn,t TO ) THEN GO TO VAL "420"
370 LET h$=d$(mm)
380 LET d$(mm)=d$(mm+sn)
390 LET d$(mm+sn)=h$
400 LET mm=mm-sn
410 IF mm>0 THEN GO TO VAL "360"
420 NEXT i
430 GO TO VAL "310"
440 CLS : PRINT "storing sorted file for SAVE..."'' FLASH 1;" stand-by... ": LET s=n: POKE a,14: FOR i=a+1 TO a+b
450 FOR j=SGN PI TO VAL "63"
460 POKE i,CODE d$(s,j)
465 IF CODE d$(s,j)=13 THEN GO TO 480
466 IF i=a+b THEN STOP
468 LET i=i+oa
470 NEXT j
480 LET s=s+oa
490 NEXT i

This is a little postscript for indxLP above. Use this listing to change the line spacing and when used with condensed font, this will allow up to 1400 records to be printed on one sheet of paper (both sides). The DATA in lines 200 and 300 are for my Fastext 80 printer. Use your printer’s manual to get the equivalents for your machine.

  10 REM change line spacing
15 GO TO 100
20 LET a=IN 127: IF a=237 THEN RETURN
22 GO TO 20
100 CLS : INPUT "1=narrow 0=normal",ls
110 IF ls THEN GO SUB 20: RESTORE 200: READ j: FOR i=1 TO j: GO SUB 20: READ k: OUT 127,k: NEXT i
120 IF NOT ls THEN GO SUB 20: RESTORE 300: READ j: FOR i=1 TO j: GO SUB 20: READ k: OUT 127,k: NEXT i
130 PRINT "Line spacing ";("Normal" AND NOT ls)+("Narrow" AND l s)
140 PRINT "Press a key for Ramdisk Menu": PAUSE 0: RANDOMIZE USR 100: GO TO 4: RANDOMIZE USR 100: NEW
200 DATA 3,27,65,8
300 DATA 2,27,50
400 STOP
1000 RANDOMIZE USR 100: SAVE "setls.B1" LINE 100

A CLOSE-SPACED LABEL

Disk Name : V01
Archives
Semi-permanent storage of
programs under development.
890316.

indxLP.Cc 001 rcp 001 index.Bx 001
rcpms.CT 001 rcpIN.B1 001 rcpIN.B2 002
rcptas.CT 001 rcpdex.CT 001 proseq.B1 001
index.B2 001 indxLP.Bb 001 wesbrz.C1 001
sysvar.Bp 001 m85-98.Bm 002 setls 001

LARKEN LKDOS 1986
Track/Side 040/002
Total Files 015
Free Blocks 062

DISK V01 DATE 890409