root Statement

The root statement provides an interface to the B-tree indexes for subsequent references with the key statement.

Syntax

root file.ref,a.code to root.var {then|else statement.block}

Parameter(s)

file.ref

File reference as a string expression.

a.code 

String expression containing the a (algebraic) processing code located in the file-defining item that identifies the index to use. The index must have previously been created with create-index.

root.var

Used by subsequent key statements.

Description

This is similar to the open statement, in that a root statement is an open of an index, and must precede a key statement just as an open statement must precede a read statement. Any number of indexes can be opened at once, provided that each has a unique root variable.

Numeric indexes will open regardless of the current case sensitivity settings. For non-numeric indexes, the case sensitivity of the index must match the current case setting, which can be set at TCL with the case command, and over-ridden in a BASIC program with the casing statement.

The optional then clause is executed if the specified index is found. The else clause is executed if it is not found.

The key statement, in conjunction with the initializing root statement, provides the ability to sequentially cruise on any defined index for a particular file.

The root statement must precede the key statement.

NOTE

The root statement leaves the parent file of an index in an open state (that is, file in use). A close statement using the root.var variable must be executed to close the parent file if a delete-file command is to be issued prior to exiting the program.

Example(s)

fname = "customer"

root fname,"a1" to cust.root else

print "file is missing"

goto 999

end

See Also

a (Algebraic) Processing Code

B-Tree

clear-index Command

create-index Command

File Reference

key Statement

Statement Blocks

Statements and Functions

then/else Statement Blocks