Creating a new table without components
How can I create a new table without using the TCreateHalcyonDataset component
Here is an example that does not use TCreateHalcyonDataset. It uses the leaner object in gs6_shel -- TgsDBFTable.
This object is ideal for console applications where the data aware capabilities inherited from TDataset are not needed:
Ensure gs6_shel.pas is in the Uses clause
procedure MakeAFile;
var
tsl: TStringList;
tbl: TgsDBFTable;
begin
tsl := TStringList.Create;
try {Add the field names, type, length, and decimal places}
tsl.Add('LASTNAME;C;30;0');
tsl.Add('FIRSTNAME;C;30;0');
tsl.Add('BIRTHDATE;D;8;0');
CreateDBF('NewFile.DBF','',FoxPro2,tsl); {File types are: Clipper,DBaseIII,DBaseIV,FoxPro2}
{you can now open the table to index it}
{This example uses TgsDBFTable object from gs6_shel.pas}
tbl := TgsDBFTable.Create('NewFile.DBF','',true,true); {ReadWrite is true, shared is true}
try
tbl.IndexOn('NewFile.CDX','NAMETAG','LASTNAME','',Duplicates,Ascending);
finally
tbl.Free;
end;
finally
tsl.Free;
end;
end;

