Define
The Define() step is where specific data definitions are established by your application and/or process. This involves defining columns/fields and creating the tables/files with optional indices. Below is the code for Define(): //--------------------------------------------------------------------------- void TForm1::Define() {
// first try to open the table bool MustCreate = false; try {
TabCustMast->Table = "custmast"; TabCustMast->Active = true; } catch (ECtError &E) {
MustCreate = true; } // if table does not exist, create it if (MustCreate) {
try {
// create the table TabCustMast->AddField("cm_custnum", CT_STRING, 5);
TabCustMast->AddField("cm_zip", CT_STRING, 10);
TabCustMast->AddField("cm_state", CT_STRING, 3);
TabCustMast->AddField("cm_rating", CT_STRING, 2);
TabCustMast->AddField("cm_name", CT_STRING, 48);
TabCustMast->AddField("cm_address", CT_STRING, 48);
TabCustMast->AddField("cm_city", CT_STRING, 48);
TabCustMast->Table = "CUSTMAST"; TabCustMast->CreateTable(); // open the table just created TabCustMast->Active = true; } catch (ECtError &E) {
Application->ShowException(&E); } } else Check_Table_Mode(TabCustMast); } void TForm1::Check_Table_Mode(TCtTable* hTable) {
try {
// And off the Transaction bit, IF it is set if (hTable->CreateMode & CTCREATE_TRNLOG) {
hTable->UpdateCreateMode(hTable->CreateMode & ~CTCREATE_TRNLOG); } } catch (ECtError &E) {
Application->ShowException(&E); } } |
|||