Equinox Online Help - Language Reference - A to Z

Home

SetIndex

Applies to
SyntaxSetIndex IndexName [, UserLoginNameExpression] [, LowerLimit] [, UpperLimit]
Action[Statement] Selects an index.
ScopeUsable anywhere (but see notes about specifying ranges).
Notes

This statement selects IndexName to be the current index. You may also use the special arguments DefaultIndex and NoIndex. If you use NoIndex or DefaultIndex for a parent table, then the records appear in their default order. This is the same for a child table, except that DefaultIndex only gives access to children of the current parent record, whereas NoIndex gives access to all child records.

If the selected index is a query index and the UserLoginNameExpression is supplied, the index instance for that user is selected, rather than the one for the current user. This powerful feature allows different user record sets on the same index to be manipulated under program control. eg Workflow systems could pass tasks between members of a group.

If you only wish to view a range of values within a table index, you can specify the top and bottom of the range using LowerLimit and UpperLimit. If you omit the top value, viewing starts from the first record in the index and if you omit the bottom value, viewing extends to the last record in the index. For multi-segment indexes, LowerLimit and UpperLimit may be specified using MakeKey values. Note that you cannot use range arguments inside subtables.

The system workarea SysError is set to a non-zero value if an error occurs, otherwise zero.

Returns SysError = 1 if the user specified is not found.

CategoryIndexes
See Also BlankIndex, CopyIndex, CurrentIndex, GroupSetIndex, IndexFromName, IndexLastUsed, IsDuplicate, KeyValues, MakeKey, MarkIndex, ModifyIndex, NameFromIndex, SetExecuteIndex, UnmarkIndex, UpdateIndex
Example

This example selects CustName as the current index and prompts the user to Find a new record.

SetIndex CustName
Find

The next method calculates the average order value for the current customer.

total = 0
norders = 0

subtable order
| choose the index accessing children only
SetIndex DefaultIndex
FirstRecord

while Not syserror
norders += 1
total += OrderTotal
NextRecord
end while
end subtable | order

Alert "No of orders: " & norders,"Order total: " & total, "Average: " & Round(total / norders,0.01)