Xbasic

CREATE_INDEXES Function

Syntax

Result as P = Create_Indexes(C tablename ,C indexDef [,L showXbasic ])

Arguments

Result

A pointer variable that contains the result of the operation. Result has the following properties:

Description
Description
. HasError

.T. = indexes could not be created .F. = indexes were created

. ErrorText

If .HasError is .T., then contains the error message.

. Xbasic

Contains the Xbasic code if Show_Xbasic is .T.

tablename

The name of the table containing the indexes to be created.

indexDef

A list of index definitions created by GET_INDEX_DEFINITIONS().

showXbasic

Logical. Optional. Default = .F. .T. = Show Xbasic code generated to create indexes.

Description

Creates indexes for a table based on a CRLF definition string. Definition string is of format: tagname|OrderExpn|FilterExpn|Flags. Tip: The format string can be created using Get_Index_Definitions().

Discussion

Creates indexes for a table based on a CR-LF delimited list created by GET_INDEX_DEFINITIONS().

Example 

The following example retrieves index definitions from a table, then (after they were manually deleted), recreates the indexes.

list = Get_Index_Definitions("index_entries")
? create_indexes("index_entries", list, .t.)
= ErrorText = ""
HasError = .F.
Xbasic = t.index_create_begin("Entry","PADR(LEFT(ENTRY,40),40,\" \") + PADR(LEFT(SUBENTRY,40),40,\" \") + PADR(LEFT(TOPIC,40),40, \" \")","","")
t.index_add("Index_Id","INDEX_ID","","U")
t.index_create_end()

See Also