As a final example of the capabilities of the B-TREE-P system, edit, compile, catalog, and execute the following LIST.NAMES program:
LIST.NAMES 001 OPEN "B-TREE" TO BFILE ELSE STOP 002 OPEN "NAMES" TO NFILE ELSE STOP 003 ID = "" ; ITEM = "" 004 CRT "ZIP, COMP, OR LNAME": 005 INPUT ROOT 006 CALL BTPFIND(ROOT,BFILE,NFILE,ID,ITEM,NODE,POS) 007 LOOP 008 READ NAMES FROM NFILE, ID ELSE NAMES = "" 009 PRINT ; PRINT ID 010 FOR AMC = 1 TO 6 011 LINE = NAMES<AMC> 012 IF LINE # "" THEN PRINT LINE 013 NEXT AMC 014 CALL BTPSEQ(BFILE, NODE, POS, "NEXT", ID) 015 UNTIL ID = "" DO REPEAT 016 STOP 017 END
LIST.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.