|
IndexTable()
Sorts a database table based on a key
expression.
Syntax
IndexTable(<cTable>, <cKey>,
[<cFor>])
Arguments
<cTable> --> Is the name of the database
table to index (temporarily sort). The table must already be open.
If not open it should be opened with the
OpenTable()
function.
<cKey> --> The key expression to sort
the table on. This must be expressed as a character string.
<cFor> --> Is an optional character
expression that defines a matching condition that must exist in the
database table for the record to be included in the index.
Returns
If the index file was successfully created its
name is returned as a character string. Otherwise if there is a
problem an empty string ( "" ) is returned.
Description
This function temporarily sorts a database table
into a customised ordering. The database table must already be open
or has been explicitedly opened using the
OpenTable()
function. The key expression defines the sorting order based on the
contents of the fields in the database.
When you have finished with the created index it
should be closed using the
CloseIndex() function.
Examples
* Sort DOCKET database
on CODE field.
OpenTable("Docket")
IndexFile :=
Docket->(IndexTable("Docket", "Code")
The next example sorts the database on CODE plus
DATE. Note that the DATE field must be converted, using the
DTOS()
function, to a character string of the format YYYMMDD to ensure
that it can be added to the CODE field (which is a character field)
and that the sorting sequence is correct.
OpenTable("Docket")
Docket->(IndexTable("Docket",
"Code+DTOS(Date)")
The next example sorts on the NAME field in
uppercase, but only for records that have a BILLING field that
equals "Y". Records that do not meet this condition are no longer
visible after the index process is completed.
OpenTable("Bins"")
Docket->(IndexTable("Bins", "Upper(Name)",
"Billed == 'Y')
Records that do not meet the condition
Billed == 'Y' will be invisible
unless the
Find()
function is used to change the sorting order, or until the table is
closed using the
CloseTable()
function.
Also see:
EraseFile()
____________________________
Related Topics
Business
Function List
CreateTable()
|