After all fields and indexes have been defined and the table properties set, it is time to create the table by calling the CreateTable() method.
Delphi Example
procedure Form1.CreateATable();
begin
try
CtTable1.Table := 'MyTable';
CtTable1.Database := CtDatabase1;
{$IFDEF WIN32} // Windows path
CtTable1.Directory := 'C:\Data';
{$ELSE} // Linux path
CtTable1.Directory := '/home/Data';
{$ENDIF}
CtTable1.AddField('Name', CT_STRING, 40);
CtTable1.AddField('Age', CT_INT2, 2);
CtTable1.AddField('Salary', CT_MONEY, 4);
CtTable1.AddIndex('Index01', CTINDEX_FIXED, True, False);
CtTable1.AddSegment('Index01', 'Name', CTSEG_USCHSEG);
CtTable1.CreateTable();
except
on E : ECtError do
Application.ShowException(E);
end;
end;
C++ Example
void Form1::CreateATable()
{
try
{
CtTable1->Name = "MyTable";
CtTable1->Database = CtDatabase1;
#ifdef __WIN32__ // Windows path
CtTable1->Directory = "C:\\Data";
#else // Linux path
CtTable1->Directory = "/home/Data";
#endif
CtTable1->AddField("Name", CT_STRING, 40);
CtTable1->AddField("Age", CT_INT2, 2);
CtTable1->AddField("Salary", CT_MONEY, 4);
CtTable1->AddIndex("Index01", CTINDEX_ FIXED, True, False);
CtTable1->AddSegment("Index01", "Name", CTSEG_USCHSEG);
CtTable1->CreateTable();
}
catch (ECtError& E)
{
Application->ShowException(&E);
}
}