void CAppConfig::CheckConfigTableL() { CDbColSet *colSet = NULL; TInt error; TRAP(error, colSet = iDb.ColSetL(KConfigTable)); if (colSet != NULL) { TBool drop = colSet->Count() != 2 || colSet->ColNo(KConfigKeyCol) == KDbNullColNo || colSet->ColNo(KConfigValueCol) == KDbNullColNo ; delete colSet; if (drop) { User::LeaveIfError(iDb.DropTable(KConfigTable)); colSet = NULL; } } if (colSet == NULL) { // Specify columns for config table TDbCol keyCol(KConfigKeyCol, EDbColText, KConfigKeyMaxLength); TDbCol valueCol(KConfigValueCol, EDbColText, KConfigValueMaxLength); keyCol.iAttributes = TDbCol::ENotNull; valueCol.iAttributes = TDbCol::ENotNull; // Add the columns to column set colSet = CDbColSet::NewLC(); colSet->AddL(keyCol); colSet->AddL(valueCol); // Create the Books table User::LeaveIfError(iDb.CreateTable(KConfigTable, *colSet)); CleanupStack::PopAndDestroy(colSet); } CDbKey *idx = NULL; TRAP(error, idx = iDb.KeyL(KConfigIndex, KConfigTable)); if (idx != NULL) { if (!idx->IsUnique()) { iDb.DropIndex(KConfigIndex, KConfigTable); delete idx; idx = NULL; } else { delete idx; } } if (idx == NULL) { TDbKeyCol keyCol(KConfigKeyCol); idx = CDbKey::NewLC(); idx->MakeUnique(); idx->AddL(keyCol); User::LeaveIfError(iDb.CreateIndex(KConfigIndex, KConfigTable, *idx)); CleanupStack::PopAndDestroy(idx); } }
void main ( void ) { ///// initialize keypad WrPortI ( PDFR,NULL,0x00 ); // parallel Port D All I/O WrPortI ( PDDCR,NULL,0xC0 ); // PD7..PD6 Open Collector WrPortI ( PDDDR,NULL,0xC0 ); // PD7..PD6 Output ///// initialize lcd WrPortI ( PADR,&PADRShadow,0x00 ); // Assure Outputs are Low WrPortI ( SPCR,&SPCRShadow,0x84 ); // parallel Port A = Outputs WrPortI ( PADR,&PADRShadow,PADRShadow&0x01 ); // Set Contrast at GND delay ( 1500 ); // Wait 15 mSec (LCD to Stabilize) lcdCmd4 ( 0x30 ); // Set to 8-Bit Interface delay ( 410 ); // Wait 4.1 mSec lcdCmd4 ( 0x30 ); // Set 8-Bit Interface delay ( 10 ); // Wait 100 uSec lcdCmd4 ( 0x30 ); // Set 8-Bit Interface lcdCmd4 ( 0x20 ); // Set 8-Bit Interface lcdCmd ( 0x28 ); // Set Dual Line Display lcdCmd ( 0x06 ); // Disable Display Shift lcdCmd ( 0x0C ); // Display On, Cursor Off lcdCmd ( 0x01 ); // Clear Screen, Home Cursor, Backlight On delay ( 164 ); // Wait 1.64 mSec for (;;) { WrPortI ( PDDR,NULL,0x40 ); // Scan Row 0 lcdGoto ( 0,0 ); // Cursor on column 0, row 0 keyCol (); // Scan for keypress WrPortI ( PDDR,NULL,0x80 ); // Scan Row 1 lcdGoto ( 0,1 ); // Cursor on column 0, row 1 keyCol (); // Scan for keypress } }
void CAppConfig::CheckAutosaveTableL() { CDbColSet *colSet = NULL; TInt error; TRAP(error, colSet = iDb.ColSetL(KAutosaveTable)); if (colSet != NULL) { TBool drop = colSet->Count() != 3 || colSet->ColNo(KAutosaveNameCol) == KDbNullColNo || colSet->ColNo(KAutosaveSaveCol) == KDbNullColNo || colSet->ColNo(KAutosaveDateCol) == KDbNullColNo ; delete colSet; if (drop) { User::LeaveIfError(iDb.DropTable(KAutosaveTable)); colSet = NULL; } } if (colSet == NULL) { // Specify columns for config table TDbCol nameCol(KAutosaveNameCol, EDbColText8, KAutosaveNameMaxLength); TDbCol saveCol(KAutosaveSaveCol, EDbColLongText8); TDbCol dateCol(KAutosaveDateCol, EDbColDateTime); nameCol.iAttributes = TDbCol::ENotNull; saveCol.iAttributes = TDbCol::ENotNull; dateCol.iAttributes = TDbCol::ENotNull; // Add the columns to column set colSet = CDbColSet::NewLC(); colSet->AddL(nameCol); colSet->AddL(saveCol); colSet->AddL(dateCol); // Create the Books table TInt _err = iDb.CreateTable(KAutosaveTable, *colSet); User::LeaveIfError(_err); CleanupStack::PopAndDestroy(colSet); } CDbKey *idx = NULL; TRAP(error, idx = iDb.KeyL(KAutosaveIndex, KAutosaveTable)); if (idx != NULL) { if (!idx->IsUnique()) { iDb.DropIndex(KAutosaveIndex, KAutosaveTable); delete idx; idx = NULL; } else { delete idx; } } if (idx == NULL) { TDbKeyCol keyCol(KAutosaveNameCol); idx = CDbKey::NewLC(); idx->MakeUnique(); idx->AddL(keyCol); User::LeaveIfError(iDb.CreateIndex(KAutosaveIndex, KAutosaveTable, *idx)); CleanupStack::PopAndDestroy(idx); } }