Xbase-Like Syntax

<< Click to Display Table of Contents >>

Navigation:  Apollo VCL Components > Technical Information >

Xbase-Like Syntax

Apollo VCL's coding syntax for TApolloTable was designed to leverage the existing knowledge of Xbase programming in migrating to a Windows environment. With this in mind, each extended TApolloTable method and property name is based on an equivalent Xbase command or function name.

 

For example, to APPEND FROM another table you call the AppendFrom method. To create a new index file, call the Index method. Search for a record in the active index with Seek, remove all records in the table with Zap, and so on. See also the various EOF options with TApolloTable.EOFAction.

 

Built-in Xbase functions allow you to continue using indexes created with Xbase-native functions like UPPER() and DTOS().

 

 

Use TApolloTable Like TTable

 

Although TApolloTable does include these xBase-like properties and methods, it is important to note that all TDataSet methods, properties, and events are also supported. So, since both TTable and TApolloTable inherit from TDataSet, you can use TApolloTable in many of the same ways as TTable. For example, although TApolloTable has a Replace method, this is mainly for backwards compatibility with older TApollo systems (before TDataSet was around), and the easier method is to just use the FieldByName method, like this:

 

 ApTbl.FieldByName('LAST').AsString := 'Smith';

 ApTbl.FieldByName('AGE').AsInteger := 21;

 ApTbl.FieldByName('MARRIED').AsBoolean := True;

 

…or, the fastest way, using persistent fields…

 

ApTblLAST.Value := 'Smith';

ApTblAGE.Value := 21;

ApTblMARRIED.Value := True;

 

Likewise, while TApolloTable also includes several Get* methods (GetString, GetInteger, etc.), these are also mainly for backwards compatibility with older TApollo systems and the new, easier technique is also to use FieldByName, like this:

 

 sLastname := ApTbl.FieldByName('LAST').AsString;

 iAge := ApTbl.FieldByName('AGE').AsInteger;

 bIsMarried := ApTbl.FieldByName('MARRIED').AsBoolean;

 

…or, the fastest way, using persistent fields…

 

 sLastname := ApTblLAST.Value;

 iAge := ApTblAGE.Value;

 bIsMarried := ApTblMARRIED.Value;

 

Similarly, instead of using the old Skip method, you can use the TDataSet.Prior or Next methods, First can be used instead of GoTop, Last can be used instead of GoBottom, Insert can be used instead of Append or AppendBlank, Post can be used instead of Commit, and BookMarks can be used instead of RecNo.

 

Besides the standard TDataSet methods, the following TTable methods (at a minimum) are currently emulated under TApolloTable:

 

AddIndex

ApplyRange

CancelRange

CloseIndexFile

CreateTable

DeleteTable

DeleteIndex

EditKey

EditRangeEnd

EditRangeStart

EmptyTable

FindKey

FindNearest

GetIndexNames

GotoCurrent

GotoKey

GotoNearest

OpenIndexFile

SetKey

SetRange

SetRangeEnd

SetRangeStart

 

 

For the complete reference on the TDataSet and TTable properties, methods, and events, please consult the Borland Delphi and/or C++Builder VCL help reference or manual.

See Also

TApolloTable.EOFAction.