RecordRef.CurrentKeyIndex([Integer]) Method
Version: Available or changed with runtime version 1.0.
Gets or sets the current key of the table referred to by the RecordRef. The current key is set or returned as a number. This first key = 1, and so on. If RecordRef does not have an active record, CURRENTKEYINDEX will return -1. If this value is then passed to KEYINDEX, an index out of bounds error will occur. Therefore it is important to implement a check of the RecordRef parameter.
Syntax
[CurrentKeyIndex := ] RecordRef.CurrentKeyIndex([NewKeyIndex: Integer])
Note
This method can be invoked using property access syntax.
Parameters
RecordRef
Type: RecordRef
An instance of the RecordRef data type.
[Optional] NewKeyIndex
Type: Integer
The number of the new key.
Return Value
[Optional] CurrentKeyIndex
Type: Integer
The number of the current key.
Example
The following example loops through four tables (36-39) opens each table as a RecordRef variable that is named MyRecordRef. The CurrentKeyIndex method retrieves the current key index of the tables. The name of the table and the current key index of each table are displayed in a message box. Each table is close before the next one is opened.
var
MyRecordRef: RecordRef;
CurrentKeyIndex: Integer;
i: Integer;
varFromTable: Integer;
varToTable: Integer;
Text000: Label 'Table: %1 Current key index: %2';
begin
varFromTable := 36;
varToTable := 39;
for i := varFromTable to varToTable do begin
MyRecordRef.Open(i);
CurrentKeyIndex := MyRecordRef.CurrentKeyIndex;
Message(Text000, MyRecordRef.Name, CurrentKeyIndex);
MyRecordRef.Close;
end;
end;
Related information
RecordRef Data Type
Get Started with AL
Developing Extensions