TASORT (Tasword Sort)

Developer(s): Bob Mitchell
Date: 1989
Type: Program
Platform(s): TS 2068

Sorts a Tasword II list of up to 240 one-line records (15360 bytes) on any column, using a Shell sort, and puts the sorted text back so it can be saved and loaded into Tasword. You need the text length, the first and last lines of the list and the column to sort on.

Listing 1 is meant to be compiled with Timachine (REM ! directives) and displays the list in 64 columns with Taswide; the one-line alternative for line 230 is for users without Taswide. Listing 2 is the loader, which loads Taswide, the compiled code and the Tasword file from a Larken disk and saves the result back with ON ERR. It needs Tasword II (and Taswide), the Timachine compiler and the Larken disk system, so there is no download.

Published in Sinc-Link January-February 1989 (Bob’s Notebook: Renumber to 10000+, TASWORD utils).

Related Articles

Let’s get back to some programming for a change. I have two interesting utilities from my notebook. 1.

Related Content

Source Code

Listing 1. Tasort
40 REM !USR 28000
50 REM ! LPRINT
60 REM ! LIST
70 REM !LEN h$<=64
80 REM !INT +oa,ob,sf,a,b,c,e,s,n,i,j,t
90 REM ! OPEN #
100 CLS
110 LET oa=SGN PI: LET ob=2: LET sf=64: LET a=47615: DIM d$(240 ,64)
120 INPUT "length of text? <=15360"'b: IF b>15360 THEN GO TO 120
130 LET c=INT (b/sf)
150 INPUT "start line? ";s
152 INPUT "end line? (0=last)";e
153 IF e=NOT PI THEN LET e=c
154 LET e1=a+((e-1)*sf)
157 CLS : PRINT "loading text from"'"line ";s;" to line ";e;".. ."
160 LET n=s
170 FOR i=a+((s-1)*sf) TO e1 STEP sf
180 FOR j=NOT PI TO 63
190 LET d$(s,j+oa)=CHR$ PEEK (i+j)
200 NEXT j
210 LET s=s+oa: IF s>e THEN GO TO 230
220 NEXT i: STOP
230 CLS : RANDOMIZE USR 64300:FOR i=n TO e: PRINT CHR$3;d$(i): NEXT i
240 BEEP oa,10: INPUT "1=sort 0=save? ";ss: IF NOT ss THEN GO TO 440
255 INPUT "sort on which col.? (1-63) ";t
260 CLS : PRINT "sorting on col. ";t: GO SUB 300: GO TO 230
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 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 360
420 NEXT i
430 GO TO 310
440 CLS : PRINT "storing sorted file for SAVE...": LET s=n: FOR i=a+((s-oa)*sf) TO e1 STEP sf
450 FOR j=NOT PI TO 63
460 POKE (i+j),CODE d$(s,j+oa)
470 NEXT j
480 LET s=s+oa: IF s>e THEN GO TO 492
490 NEXT i
492 STOP
495 REM ! CLOSE #
550 CLEAR : RANDOMIZE USR 100: SAVE "tasort.Bp" LINE 100

Line 230 without Taswide
CLS: FOR i=n TO e: PRINT d$(i): NEXT i

Listing 2. The loader
5 CLS : PRINT INVERSE 1;"TASWORD SORT"; INVERSE 0;" by Bob Mitchell."''"This utility will sort Tasword lists of up to 240 lines (15360 bytes)."
6 PRINT '"Have the following parameters ready from SAVED list:"''"1. text length"'"2. start line number"'"3. end line number if not last"'"4. column # to sort on (1-63)."
7 PRINT '"Install disk containing list to be sorted; then, press a key.": PAUSE 0
8 RANDOMIZE USR 100: LOAD "taswi.Cx"CODE : RANDOMIZE USR 100: LOAD "tasort.Cc"CODE 28000
10 INPUT " TASWORD SORT "'"list name? max 6 "; LINE n$: RANDOMIZE USR 100: LOAD n$+".CT"CODE 47615
20 ON ERR GO TO 25: RANDOMIZE USR 28000: GO TO 30
25 ON ERR RESET: POKE 23607,60: GO TO 55
30 LET b=PEEK 30078+256*PEEK 30079: REM see note 1.
40 INPUT "list name? max 6 "; LINE n$: RANDOMIZE USR 100: SAVE n$+".CT"CODE 47615,b
50 CLS : PRINT "Sorted file has been saved and is ready for loading into Tasword"
55 INPUT "1=more  0=quit ";m
56 IF m THEN GO TO 5
57 IF NOT m THEN STOP
60 CLEAR : RANDOMIZE USR 100: SAVE "tasort.Bb" LINE 5

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.