0 PRINT"This file is designed to assist you in learning to use the JETSAM commands in the BASIC 1 PRINT"supplied with the PCW. These are very powerful commands which enable you to use BASIC 2 PRINT"as a database language for the storage of data, and many commercial programs have been 3 PRINT"written in BASIC which use the JETSAM functions. Essentially, each record is referenced 4 PRINT"by one or more keys, the keys being up to 31 characters long. The keys are stored in 5 PRINT"alphabetical order. Integers may be used as keys - uses BASIC's MKIK$(a%) function. 6 PRINT"Each file has 8 ranks (numbered 0..7), and each key is in one of these. You'll find 7 PRINT"instructions in the BASIC manual, but often they aren't clear... so this file may well 8 PRINT"help you. What do you use JETSAM for? I've used it for sorting information into 9 PRINT"alphabetical order, for accounting word, for cross referencing, databases, label 10 PRINT"printing, making a spelling checker, in the word count program etc. etc. etc. 11 PRINT:PRINT"Keith Simons.":PRINT:PRINT 12 TYPE JETSAM.BAS 100 GOTO 25000:END 'That's a long program!!! 110 ' 200 'SUBROUTINE 1 210 'How to delete a record 220 rc%=DELKEY (#file%,2) 230 IF rc%>103 THEN PRINT "Failed to Delete with code ";rc% 240 'Remember before you use this to find the correct key first! 250 RETURN 260 ' 300 'SUBROUTINE 2 310 'How to stop the rank having duplicate keys 320 rc%=RANKSPEC (#file%,rank%,1) 330 IF rc%<>0 THEN PRINT "Failed to Prevent Duplicate Keys with code ";rc% 340 'Remember to specify the appropriate rank first. 350 RETURN 360 ' 400 'SUBROUTINE 3 410 'How to find a key called required$ 420 rc%=SEEKKEY (#file%,2,rank%,required$) 430 IF rc%<>0 THEN PRINT "Failed to Find ";required$;" with code ";rc% 440 IF rc%=105 THEN PRINT "Succeeded in finding the key following ";required$ 450 RETURN 460 ' 500 'SUBROUTINE 4 510 'How to find the first key in rank% 520 rc%=SEEKRANK (#file%,2,rank%) 530 IF rc%<>0 THEN PRINT "Failed to find any keys in ";rank%;" with code ";rc% 550 RETURN 560 ' 600 'SUBROUTINE 5 610 'How to find the next key in the file 620 rc%=SEEKNEXT(#file%,2) 630 IF rc%>102 THEN PRINT "Failed to find the next key with code ";rc% 640 IF rc%<>0 THEN PRINT "This key has a different value to the last - code ";rc% 650 RETURN 660 ' 700 'SUBROUTINE 6 710 'How to find the previous key in the file 720 rc%=SEEKPREV(#file%,2) 730 IF rc%>102 THEN PRINT "Failed to find the previous key with code ";rc% 740 IF rc%<>0 THEN PRINT "This key has a different value to the last - code ";rc% 750 RETURN 760 ' 800 'SUBROUTINE 7 810 'How to find the next key in the file, different to the present one 820 rc%=SEEKSET(#file%,2) 830 IF rc%>102 THEN PRINT "Failed to find the next different key with code ";rc% 840 IF rc%=102 THEN PRINT "This key has a different rank from the last" 850 RETURN 860 ' 900 'SUBROUTINE 8 910 'How to add a new record with its key (required$) to the file 920 rc%=ADDREC(#file%,2,rank%,required$) 930 IF rc%<>0 THEN PRINT "Failed to add the new record under the key ";required$;" with code ";rc% 940 IF rc%=116 THEN PRINT "This rank is marked to reject duplicates and ";required$;"is already in use" 950 RETURN 960 ' 1000 'SUBROUTINE 9 1010 'How to mark #file% consistent and still have it open 1020 rc%=CONSOLIDATE (#file%) 1030 IF rc%<>0 THEN PRINT "Failed to make file consistent" 1050 RETURN 1060 ' 1100 'SUBROUTINE 10 1110 'How to find out the current record number (record%) 1120 record%=FETCHREC (#file%) 1130 IF record%=0 THEN PRINT "Failed as the current position is unset" 1150 RETURN 1160 ' 1200 'SUBROUTINE 11 1210 'How to find out the last key entry found (required$) 1220 required$=FETCHKEY$ (#file%) 1250 RETURN 1260 ' 1300 'SUBROUTINE 12 1310 'How to add a new key (new.key$) into rank% for record% 1320 rc%=ADDKEY (#file%,2,rank%,new.key$,record%) 1330 IF rc%<>0 THEN PRINT "Failed to add the new key to the record with code ";rc% 1340 IF rc%=116 THEN PRINT "This rank is marked to reject duplicates and ";new.key$;" is already in use" 1350 RETURN 1360 ' 1400 'SUBROUTINE 13 1410 'How to create new JETSAM files called file1$ and file2$, with record length r% 1420 BUFFERS 6:CREATE file%,file1$,file2$,2,r% 1430 RETURN 1440 'Note - the record length must be 2 more than the actual length defined by FIELD 1450 'FIELD is used just like in random access - eg :FIELD file%,126 as a$ 1460 'When you are inspecting records, use :GET file%: 1470 'Use :PUT file%: to PUT a record. 1480 ' 1500 'SUBROUTINE 14 1510 'How to open JETSAM files, file1$ and file2$ 1520 BUFFERS 6:OPEN "K",file%,file1$,file2$,2,rc% 1530 PRINT "File length is"rc% 1540 RETURN 1550 ' 1600 'SUBROUTINE 15 1610 'How to close a JETSAM file 1620 CLOSE file% 1630 RETURN 1640 'Note - This command or CONSOLIDATE must be used before BUFFERS,CLOSE,SYSTEM, or RUN 1650 ' 25000 IF FIND$("M:$$$$$$$$.&&&")<>"" THEN OPTION STOP:PRINT "[Press any key to return to main menu or press (STOP) to stop]":z$=INPUT$(1):RUN "M:$$$$$$$$.&&&":ELSE END O