<< Click to Display Table of Contents >> Navigation: Apollo VCL Components > Apollo VCL Component Reference > TApolloTable > TApolloTable Methods > FieldOffset |
Declaration
function FieldOffset( sFieldName: String ): Word;
Description
Gets offset of named field in record buffer (relative to 1). The first field will always have an offset of 2. The deletion flag offset is 1.
Useful if using ApolloGetRecord to read the contents of a complete record into a string buffer.
Parameters
sFieldName: The name of the field.
Return Value
The offset of the named field into the record buffer (relative to 1). If the field name is invalid, zero is returned.
Delphi Example
procedure Form1.Button1Click(Sender: TObject);
var
//Same size as table record
cRecBuff: Array[0..500] of Char;
// Temp buff used in copying
cTempBuff: Array[0..254] of Char;
sFldName, sFldData: String;
i: Integer;
begin
with ApTbl do
begin
// Extract record
ApolloGetRecord( cRecBuff );
// Fill list box with record data
for i := 1 to ApolloFieldCount do
begin
// Get field name
sFldName := FieldName( i );
// Get field data (Must extract it out of PChar)
sFldData := StrPas( StrLCopy( cTempBuff, @cRecBuff[ FieldOffset( sFldName )-1 ],FieldWidth( sFldName ) ));
// Add field data to list box
ListBox1.Items.Add( sFldData );
end;
end;
end;
See Also
ApolloFieldCount, FieldDecimals, FieldName, FieldNum, FieldType, FieldWidth