Creating GET.NAMES
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.NAMES001 OPEN "NAMES" TO NFILE ELSE STOP002 LOOP003 CRT "ID NUMBER":004 INPUT ID005 UNTIL ID = "" DO006 READ ITEM FROM NFILE, ID ELSE ITEM = ""007 AMC = 1 ; LABEL = "FIRST NAME" ; GOSUB 100008 AMC = 2 ; LABEL = "LAST NAME" ; GOSUB 100009 AMC = 3 ; LABEL = "COMPANY" ; GOSUB 100010 AMC = 4 ; LABEL = "ADDRESS" ; GOSUB 100011 AMC = 5 ; LABEL = "CITY ST" ; GOSUB 100012 AMC = 6 ; LABEL = "ZIP CODE" ; GOSUB 100013 CRT "EXIT, FILE, OR DROP":014 INPUT COMMAND015 BEGIN CASE016 CASE COMMAND = "FILE"017 WRITE ITEM ON NFILE, ID018 CASE COMMAND = "DROP"019 DELETE NFILE, ID020 CASE 1021 CRT "EXITING"022 END CASE023 REPEAT024 STOP025 *026 100 CRT "OLD ":LABEL:"=":ITEM<AMC>027 CRT "NEW ":LABEL:028 INPUT NEW029 IF NEW # "" THEN030 IF NEW = "\" THEN NEW = ""031 ITEM<AMC> = NEW032 END033 RETURN034 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.