SERCH - GENERALIZED BINARY FILE SRAECH SUBROUTINE SERCH is an AlphaBASIC subroutine that handles binary ans sequential searching of disk files. It allows your program to access a file via symbolic keys, without paying the overhead costs of ISAM. The files used by the SERCH subroutine are standard random access (i.e., contiguous) files. To allow the use if binary search techniques, but avoid the need to sort the data file each time an addition is made, SERCH supports an overflow area. When SERCH is called, the number of sorted records is given. A binary search is performed on the sorted area. If the specified record is not found, a sequential search of the overflaw area is performed. Options allow control over when a binary search and/or a sequential search is performed. SERCH is called by the following: XCALL SERCH, CHANEL, REDREC, KEY, STPOS1, ENPOS1, BSEND, BSMID, SRCCTL, SRCOPT, RCNOST, RCNOEN, STPOS2, ENPOS2, STPOS3, ENPOS3 Where: CHANEL Channel on which file to be searched is currently open for ramdom processing. (File #) REDREC String or unformatted variable in which found record is returned. KEY String specifying key to be searched for. If more than one key position is being used, this varaible contains all of the keys, concatenated together. STPOS1 The first character position in the file record occupied by key #1. ENPOS1 The last character position in the file record occupied by key #1. BSEND The number of sorted records in the file. BSMID The relative record number of the found record is returned in this variable. SRCCTL Completion code returned by SERCH: 0 = record was found. 1 = record was not found. SRCOPT Varaible specifying the type of search to be performed: 1 = display the "PLEASE WAIT" message, perform a binary search, clear the message, and return. 2 = Perform a binary search, clear line 12 of the screen, and return. 3 = Display the wait message, perform a binary search, and return. 4 = Perform a binary search and return. 5 = Perform a sequential search starting with the record specified by BSMID. RCNOST The first character position within the file record used to denote record deletion. A record is flagged as deleted if the positions specified by RCNOST and RCNOEN contain binary zero. This zero may be in form of a binary variable containing zero, a flaoting point number containing zero, or a string containing a null. RCNOEN The last character position within the file record used to denote record deletion. See RCNOST above. STPOS2 The starting position of key #2 within the file record. If key #2 is not used, this should be zero. ENPOS2 The ending position of key #2 within the file record. STPOS3 The starting position of key #3 within the file record. If key #3 is not used, this should be zero. ENPOS3 The ending position of key #3 within the file record. All unused records in the file (i.e., thise beyond the overflow area) must contain right square brackets (]) in the first six characters of the record. This is used to detect the end of the area to be searched. The SERCH subroutine makes use of FLTCNV.PRG, which must be loaded into user or system memory before SERCH.SBR is used (AMOSL systems ignore.) SERCH if fully reentrant and may be loaded into system memory.