Delphi-level interface
Delphi-level interface is defined in HbDelphi.pas file. Two objects are available to facilitate programming on Delphi level.
THbConnection - object of this class encapsulates all global (not table-related) methods. Additionaly, for Mediator it is used to encapsulate Mediator connection status available via Connected property. You always need exactly one instance of this class. Remember to create THbConnection object before calling any interface function.
THbTable - objects of this class are used to encapsulate workarea-related functionality. You need separate THbTable object for each concurrently open table or Mediator SQL query. When table is opened via DbUseArea or DbUseSqlArea method, the object is tied to the Harbour workarea allocated to the open table.
The same THbTable object can be used to hold different tables at a time. When you close the open table with DbCloseArea method you are free to open the new one using DbUseArea method. When opening table in THbTable object you need to specify RDD driver to be used when opening table. The following RDD drivers are supported by our Delphi-level interface:
Harbour drivers: DBFNTX, DBFCDX
Mediator drivers: MEDNTX, MEDCDX
After opening table using DbUseArea or DbUseSqlArea you can check for success using THbTable.NetErr function of THbTable.Active property (prefered method).
Access to field values is implemented via [] (square brackets) default property. To reference value of field named FIELD1 from THbTable tab use tab['field1']. Case of the field name dos not matter here.
Sample:
var
hbc: THbConnection;
tab: THbTable;
begin
// creating objects
hbc := THbConnection.Create;
tab := THbTable.Create(hbc);
tabb.DbUseArea('DBFNTX','dbtest',false); // opens dbtest in Exclusive mode
if not tab.Active then
begin
writeln('Error opening dbtest');
Exit;
end;
tab.DbGoTop; // go top
tab.DbSkip; // skip to second record
writeln( tab.Recno, tab['field1'], tab[field2']); // write RECNO and values in FIELD1 and FIELD2
tab.DbCloseArea; // close table
// destroying objects
tab.Destroy;
hbc.Destroy;
end;
All THbConnection and THbTable methods directly correspond to appropriate Harbour or Mediator functions with same names. Use CA-Clipper/Harbour and Mediator manual for detailed documentation of their use. Some functions are overloaded i.e. there are several functions with the same name but different parameters. Choose the one which is most suitable for you.
Some methods (eg. DbUseArea) have default values specified for their parameters. If defaults suit your needs, you do not need to specify these values on function call.
Sample:
tab.DbUseArea('DBFNTX','dbtest'); // opens table in shared read/write mode
tab.DbUseArea('DBFNTX','dbtest',flase); // opens table in exclusive read/write mode
tab.DbUseArea('DBFNTX','dbtest',flase,true); // opens table in exclusive read only mode
All supported functions are defined in HbDelphi.pas file. When you need to find how to use any particular Clipper/Harbour function, please find its definition in HbDelphi.pas file inspect its definition and choose the best version if function is overloaded.