This issue of BTP/Branches will be using a simple name and address file and update program to demonstrate how B-TREE-P works. The file containing the names and addresses is called NAMES, and GET.NAMES is the program to create or change records in the NAMES file.
To create the GET.NAMES program on your system so that it can serve as the basis for further B-TREE-P demonstrations, give the command EDIT BP GET.NAMES, then use the Editor to create the GET.NAMES program using the following source code:
GET.NAMES 001 OPEN "NAMES" TO NFILE ELSE STOP 002 LOOP 003 CRT "ID NUMBER": 004 INPUT ID 005 UNTIL ID = "" DO 006 READ ITEM FROM NFILE, ID ELSE ITEM = "" 007 AMC = 1 ; LABEL = "FIRST NAME" ; GOSUB 100 008 AMC = 2 ; LABEL = "LAST NAME" ; GOSUB 100 009 AMC = 3 ; LABEL = "COMPANY" ; GOSUB 100 010 AMC = 4 ; LABEL = "ADDRESS" ; GOSUB 100 011 AMC = 5 ; LABEL = "CITY ST" ; GOSUB 100 012 AMC = 6 ; LABEL = "ZIP CODE" ; GOSUB 100 013 CRT "EXIT, FILE, OR DROP": 014 INPUT COMMAND 015 BEGIN CASE 016 CASE COMMAND = "FILE" 017 WRITE ITEM ON NFILE, ID 018 CASE COMMAND = "DROP" 019 DELETE NFILE, ID 020 CASE 1 021 CRT "EXITING" 022 END CASE 023 REPEAT 024 STOP 025 * 026 100 CRT "OLD ":LABEL:"=":ITEM<AMC> 027 CRT "NEW ":LABEL: 028 INPUT NEW 029 IF NEW # "" THEN 030 IF NEW = "\" THEN NEW = "" 031 ITEM<AMC> = NEW 032 END 033 RETURN 034 END
(Note: the EDIT command just described, and other commands described in the rest of this issue, assume that your account has a file called BP where BASIC programs are kept. If necessary, use the proper form of the CREATE-FILE command to create a file named BP before you give the EDIT command. Since Pick systems often vary in exactly what commands are available and how the commands are structured, always check your system's documentation to be sure the format of your commands is the same as those described here.)
Once you have created the GET.NAMES program using the Editor, give the command BASIC BP GET.NAMES to compile the program and check for syntax errors. If your compiler does not allow CRT statements in BASIC programs, change every occurrence of CRT to PRINT.