Listing NAMES in order
As a final example of the capabilities of the B-TREE-P system, edit, compile, catalog, and execute the following LIST.NAMES program:
LIST.NAMES001 OPEN "B-TREE" TO BFILE ELSE STOP002 OPEN "NAMES" TO NFILE ELSE STOP003 ID = "" ; ITEM = ""004 CRT "ZIP, COMP, OR LNAME":005 INPUT ROOT006 CALL BTPFIND(ROOT,BFILE,NFILE,ID,ITEM,NODE,POS)007 LOOP008 READ NAMES FROM NFILE, ID ELSE NAMES = ""009 PRINT ; PRINT ID010 FOR AMC = 1 TO 6011 LINE = NAMES<AMC>012 IF LINE # "" THEN PRINT LINE013 NEXT AMC014 CALL BTPSEQ(BFILE, NODE, POS, "NEXT", ID)015 UNTIL ID = "" DO REPEAT016 STOP017 ENDLIST.NAMES begins by prompting for a B-tree name. Type the word ZIP, COMP, or LNAME, and LIST.NAMES then immediately lists all items in the NAMES file in the order you selected. Since the appropriate B-tree is used to determine the order of names, LIST.NAMES does not have to wait for a sort to finish before it can begin printing.