VADELIA |
SADELIA |
WADELIA |
MADELIA |
(I/B) (C/S) |
(B) (S) |
(I/B) (C/S) |
(I) (C/S) |
Section for use
DECLARATION
Syntax
LIST_INDEX IndexName ListName NextAccessFields
NextAccessField |
→ |
NextAccessFields, AccessField | AccessField Direction |
Direction |
→ |
*ASC | *DESC | None |
Description
This instruction is used to declare an index for a list.
The list must be a memory list (not a graphical list, or the LIST property of a GRAPHICAL_OBJECT type variable).
The index access fields cannot be IMAGE fields.
Notes: Indexes are only when first read (see 4GL index handling instructions).
Declaring many indexes for a list will reduce performance slightly when this list is modified (addition, deletion, etc.), as the indexes are all automatically updated. We therefore recommend only creating the indexes (via READ_ELT, READ_F_ELT and READ_L_ELT) at the time of their use, then to delete them if they are no longer required (via DELETE_INDEX).
At the most 10 indexes can be declared for a given list.
The item read by an index becomes the current list item, assigning values to the variables comprising the list.
Indexes are not transmitted during client/server management. Consequently, must not be read in client/server mode (the read operation will fail). Moreover, an index is considered out of data at the start of service, if the list for which it is declared has been received by this server.
Example
LIST MyList Field1 Field2 Field3 Field4
LIST_INDEX MyIndex1 MyList Field1
LIST_INDEX MyIndex2 MyList Field1 *DESC
LIST_INDEX MyIndex3 MyList Field3 *DESC, Field2 *DESC
Notes concerning parameter lists:
In the case of a program parameter list, any indexes defined for this list are transmitted and updated when the list is modified (hence the advantage of destroying them in the calling program if they are not required). They can thus be handled as newly declared in this program: the access fields must be the same, even if their name differs.
Example:
/* Program no. 1
LIST MyList Field1 Field2 Field3 Field4
INDEX MyIndex1 MyList Field2
CALL Program2 MyList
/* Program no. 2
LIST MyParamList P2_Field1 P2_Field2 P2_Field3 P2_Field4
LIST_INDEX NewIndex MyParamList P2_Field2
/* This index is not genuinely new, as the list is a parameter and it already possesses an index with an identical definition (even though the field name was Field2 in the first program and P2_Field2 in this case, and that the indexes do not have the same name).
LIST_INDEX MyIndex1 MyParamList P2_Field2 *DESC
/* This index is genuinely new as, though it has the same name as an index already declared for this list by another program, there is as yet no index with this access definition (2nd field of the list in descending order).
PARAM MyParamList
INSERT_ELT MyParamList
/* This list modification updates the index defined for the original list declared in program no. 1.