Click or drag to resize

OrdKeyVal Function

X#
Get the key value of the current record from the controlling order.

Namespace:  XSharp.RT
Assembly:  XSharp.RT (in XSharp.RT.dll) Version: 2.19
Syntax
 FUNCTION OrdKeyVal(
	uOrder,
	cIndexFile
) AS USUAL CLIPPER
Request Example View Source

Parameters

uOrder (Optional)
Type: Usual
cIndexFile (Optional)
Type: Usual

Return Value

Type: Usual
The current record's key value.
The data type of the return value is the same as the that of the key expression used to create the order.
Use ValType() or UsualType() to determine the data type. OrdKeyVal() returns NIL if: The is no controlling order The record pointer is at the end-of-file (EOF() returns TRUE) There is no key defined for this record (for example, you have positioned the record pointer to a record that does not meet the order's for condition or that lies outside of its specified scope)
Remarks
The key value is retrieved from the controlling order, not the database file.
This makes the retrieval faster because no time is spent reading in the actual record. Tip: OrdKeyVal() is fast, but if you are going to use the value more than once, it is faster to store the result in a local variable.
Then use the local variable rather than calling OrdKeyVal() repeatedly for the same record. By default, this function operates on the currently selected work area.
It can be made to operate on an unselected work area by specifying it within an aliased expression
Examples
This example displays the values for all keys in an order without ever reading the individual records into memory:
X#
1FUNCTION DisplayKeys()
2    LOCAL cKey, cFirst, cLast
X#
1USE customer
2// Assuming both LastName and FirstName are
3// 20 characters
4INDEX ON LastName + FirstName TO lastfir
X#
 1DO WHILE !Customer->EOF()
 2    cKey := Customer->OrdKeyVal()        // Get key
 3                            // value
 4    cLast := LEFT(cKey, 20)            // Get last
 5                            // name
 6    cFirst := RIGHT(cKey, 20)        // Get first
 7                            // name
 8    ? cLast, cFirst
 9    Customer->DBSkip()
10ENDDO
X#
1CLOSE
See Also