Index Examples

Example 1 opens the customer table and creates an index file named complist, which displays and processes records in the alphabetic order of the company field.

In Example 2, the customer table is again opened and an index file named citycomp is created from a substring of the first five characters of the city field and the first six characters of the company field. When this index file is used, records in the table are ordered primarily according to the city field and secondarily according to the company field.

In Example 3, index tags are created. The first tag is a structural compound index tag for address. The second tag is created in a non-structural index file named custcdx.

* Example 1
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE Customer     && Open customer table
INDEX ON company TO complist
CLEAR
DISPLAY STATUS

* Example 2
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE Customer     && Open customer table
INDEX ON SUBSTR(city,1,5) + SUBSTR(company,1,6) TO citycomp
CLEAR
DISPLAY STATUS

* Example 3
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE Customer     && Open customer table
INDEX ON address TAG address
INDEX ON company TAG company OF custcdx
CLEAR
DISPLAY STATUS