Please enable JavaScript to view this site.

A-Shell Reference

xcall SERCH, ch, rec, key, stpos1, enpos1, bsend, bsmid, srcctl, srcopt, rcnost, rcnoen, stpos2, enpos2, stpos3, enpos3

SERCH is used for searching index files that consist of a sorted area and an unsorted "overflow" area. The sorted area is searched using a binary search routine, while the overflow area is searched sequentially. At best, binary searching is nowhere near as efficient as ISAM index lookups, and this discrepancy gets rapidly worse as the size of the overflow area increases, so it is not a highly recommended indexing technique. Nevertheless it is quite common, due to its use in the old AlphaAccounting programs and concerns in the early days about the reliability of ISAM.

Parameters

ch (Num)

is the open file channel of the index file.

rec (BLOB, 2048 bytes maximum)

is an unformatted area for the located index record to be returned in.

key (String)

is the string key to search for. This can consist of up to 3 parts (corresponding to the stpos1, enpos1, stpos2, enpos2, stpos3 and enpos3 locations in the index record), all of which must be concatenated together.

stpos1, enpos1, stpos2, enpos2, stpos3, enpos3  (Num)

specify the starting and ending position of up to 3 segments of the index record which make up the key to search for.

bsend (Num)

is the number of records in the sorted portion of the file (which must begin at the first record in the file).

bsmid (F,6)

will return the record number of the located index record.

srcctl (F,6)

returns a completion code (0=found, 1=not found)

srcopt (Num)

specifies the type of search to perform:

Value

Search Type

1

Display "Please Wait" on line 12 of the screen, perform a binary/sequential search, clear the message, and return.

2

Perform a binary/sequential search, clear line 12 of the screen, and return

3

Display the wait message, perform a binary/sequential search, and return

4

Perform a binary/sequential search and return (without any display)

5

Perform a sequential search only, starting with the record number specified by bsmid.

6

Perform a binary/sequential search which guarantees the locating of the first of a series of identical keys. (The other binary search options do not guarantee this.)

 

By "binary/sequential" in the table above, we mean that it first performs a binary search on the sorted portion of the index file, and if the record is not found, it then performs a sequential search on the overflow area.

rcnost, rcnoen

mark the starting and ending positions within the record that are used to indicate a deleted record. This area must be at least 2 bytes long, and each of the bytes must contain binary zero. (You can create such a binary field by setting a variable of type F or B to zero, in which case all of the bytes of the variable will contain 0, or by setting a string variable to "".)

 

Comments

The speed of SERCH can be increased dramatically by using one of the techniques described in the discussion of Xcall ASFLAG. It also goes without saying that you should sort the file as needed to keep the overflow area from growing very large.

History

2010 March, A-Shell 5.1.1176: XCALL SERCH enhancement: indexes using span'blocks (including record sizes up to 2048). Previously it only supported record sizes up to 512 with traditional blocking.