|
/* Palm OS/AnsiC code for an EN/SK translator. - Data are compressed using Huffman compressing algorithm. - Database is a regular PalmOS in-memory database. - User interaction is handled by responding to messages generated by OS. - Code has been created following series of articles published at palmare.cz. Igor Klepoch, 2001 */ #include <PalmOS.h> #include "slovnik.h" #include "form.h" #include "libr.c" // Definice funkci Err ZacatekProgramu(); void KonecProgramu(); void ZpracovaniUdalosti(); Boolean UdalostFormularPredvData (EventPtr udalost); Boolean UdalostZpracovanaAplikaci(EventPtr udalost); Boolean UdalostIDFormularPredvolbyItems (EventPtr udalost); Boolean ObslIDFormularPreklad(EventPtr udalost); Boolean UdalostEcho (EventPtr udalost); Boolean ObslIDFormularList (EventPtr udalost); void MainViewTableInit(void); Err CustomLoadItem (void * table, Int16 row, UInt16 column, Boolean editing, MemHandle * textH, UInt16 * textOffset, UInt16 * textAllocSize, FieldPtr fld); void ZobrazAnSlovo(); static Int16 lLastRecord; static Int16 StavAppl; static Int16 SelRecordDetail; MemHandle TableResult; Int16 FirstWord = 0; static char* SlovnikItems [DlzkaStrany]; void Zmen (char * newValue); Err ZacatekProgramu() { Err err = errNone; err = pdb_Open (&DBPredvolby, "SlovnikDB", 'Slov'); if (err) return err; InitDBPredvolby(); FrmGotoForm(IDFormularList); lLastRecord = 0; StavAppl = 0; return 0; } void KonecProgramu() { FrmSaveAllForms (); FrmCloseAllForms (); pdb_Close (&DBPredvolby); } void PadR (char* PStr, Int8 Dlzka, char AddChar) { Int8 i, j; j = StrLen(PStr) + 1; (UInt32)PStr += StrLen(PStr); for (i = j; i < 59; i++) { *PStr = AddChar; ++PStr; } *PStr = 0; } void ZobrazPrekladSlovo(Int32 DBRiadok) { UnPackCisloItemType RUnPackRec; MemHandle recordH; CisloItemPtr MRec; Int8 SlDlzka; char* VyslStr; char* PStr; Int16 myLabelObjectIndex; FormPtr frm = FrmGetActiveForm(); if (DBRiadok < pdb_RecNo (&DBPredvolby)) { recordH = DmQueryRecord (DBPredvolby.DBHandle, DBRiadok); ErrFatalDisplayIf ((! recordH), "Record not found"); MRec = (CisloItemPtr) MemHandleLock (recordH); UnPackPredvolby(&RUnPackRec, MRec); } else { NullDBPredvolby(&RUnPackRec); StrCopy(RUnPackRec.AnSlovo, "*"); StrCopy(RUnPackRec.SlSlovo[1], "*"); }; SlDlzka = StrLen(RUnPackRec.AnSlovo); recordH = MemHandleNew(SlDlzka + 1); ErrFatalDisplayIf ((! recordH), "No free memory"); SlDlzka = StrLen(RUnPackRec.AnSlovo); SlDlzka = SlDlzka > DlzkaZorsSLovaAN ? DlzkaZorsSLovaAN : SlDlzka; VyslStr = MemHandleLock (recordH); PStr = VyslStr + SlDlzka; StrNCopy(VyslStr, RUnPackRec.AnSlovo, SlDlzka); *PStr = 0; FrmCopyTitle (FrmGetActiveForm(), VyslStr); MemHandleUnlock (recordH); MemHandleFree (recordH); SlDlzka = StrLen(RUnPackRec.SlSlovo[0]); recordH = MemHandleNew(SlDlzka + 1); ErrFatalDisplayIf ((! recordH), "No free memory"); VyslStr = MemHandleLock(recordH); SlDlzka = StrLen(RUnPackRec.SlSlovo[0]); SlDlzka = SlDlzka > DlzkaZorsSLovaAN ? DlzkaZorsSLovaAN : SlDlzka; PStr = VyslStr + SlDlzka; StrNCopy(VyslStr, RUnPackRec.SlSlovo[0], SlDlzka); *PStr = 0; myLabelObjectIndex = FrmGetObjectIndex(frm, LPSlovo2); FrmHideObject(frm, myLabelObjectIndex); FrmCopyLabel(frm, LPSlovo2, VyslStr); FrmShowObject(frm, myLabelObjectIndex); MemHandleUnlock(recordH); MemHandleFree (recordH); SlDlzka = StrLen(RUnPackRec.SlSlovo[2]); recordH = MemPtrNew(DlzkaZorsSLovaAN + 1); StrNCopy((char*)recordH, RUnPackRec.SlSlovo[2], DlzkaZorsSLovaAN); PadR ((char*)recordH, DlzkaZorsSLovaAN, 32); ctl = GetObjectPtr (LPSlovo2); CtlSetLabel (ctl, (char*) recordH); } void ZobrazJedenRiadok (Int32 DBRiadok, Int16 ObrRiadok) { UnPackCisloItemType RUnPackRec; MemHandle recordH; char* VyslStr; static char* PStr; CisloItemPtr MRec; Int8 SlDlzka; Int16 ObjNum; Int16 myLabelObjectIndex; FormPtr frm = FrmGetActiveForm(); if (DBRiadok < pdb_RecNo (&DBPredvolby)) { recordH = DmQueryRecord (DBPredvolby.DBHandle, DBRiadok); ErrFatalDisplayIf ((! recordH), "Record not found"); MRec = (CisloItemPtr) MemHandleLock (recordH); UnPackPredvolby(&RUnPackRec, MRec); MemHandleUnlock (recordH); } else { NullDBPredvolby(&RUnPackRec); StrCopy(RUnPackRec.AnSlovo, "***"); }; SlDlzka = StrLen(RUnPackRec.AnSlovo); recordH = MemHandleNew(SlDlzka + 1); ErrFatalDisplayIf ((! recordH), "No free memory"); VyslStr = MemHandleLock(recordH); SlDlzka = StrLen(RUnPackRec.AnSlovo); SlDlzka = SlDlzka > DlzkaZorsSLovaAN ? DlzkaZorsSLovaAN : SlDlzka; PStr = VyslStr + SlDlzka; StrNCopy(VyslStr, RUnPackRec.AnSlovo, SlDlzka); *PStr = 0; myLabelObjectIndex = FrmGetObjectIndex(frm, LSlovo1 + ObrRiadok); FrmHideObject(frm, myLabelObjectIndex); FrmCopyLabel(frm, LSlovo1 + ObrRiadok, VyslStr); FrmShowObject(frm, myLabelObjectIndex); MemHandleUnlock(recordH); MemHandleFree (recordH); } void ZobrazAnSlovo() { Int16 i; for (i = 0; i < DlzkaStrany; ++i) ZobrazJedenRiadok (FirstWord + i, i); } UInt32 PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { Err chyba; if (cmd == sysAppLaunchCmdNormalLaunch) { chyba = ZacatekProgramu(); if(chyba) { return chyba; } ZpracovaniUdalosti(); KonecProgramu(); } return 0; } void ZpracovaniUdalosti() { EventType udalost; do { EvtGetEvent(&udalost, evtWaitForever); if (SysHandleEvent(&udalost)) continue; if(UdalostZpracovanaAplikaci(&udalost)) continue; FrmDispatchEvent(&udalost); } while(udalost.eType != appStopEvent); } Boolean UdalostZpracovanaAplikaci(EventPtr udalost) { Boolean zpracovano = false; UInt16 cisloFormulare; FormPtr formular; if(udalost->eType == frmLoadEvent) { cisloFormulare = udalost->data.frmLoad.formID; formular = FrmInitForm(cisloFormulare); FrmSetActiveForm(formular); switch(cisloFormulare) { case IDFormularList: FrmSetEventHandler(formular, ObslIDFormularList); zpracovano = true; break; case IDFormularPreklad: FrmSetEventHandler(formular, ObslIDFormularPreklad); zpracovano = true; break; default: break; } } return zpracovano; } Boolean ObslIDFormularPreklad(EventPtr udalost) { Boolean zpracovano = false; switch(udalost->eType) { case frmOpenEvent: ZobrazPrekladSlovo(FirstWord + 1); FrmDrawForm(FrmGetActiveForm()); zpracovano = true; break; case ctlSelectEvent: if (udalost->data.ctlEnter.controlID == bCancel ) // Cancel { StavAppl = 0; FrmGotoForm(IDFormularList); zpracovano = true; break; } if (udalost->data.ctlEnter.controlID == BtnDn ) // Delete { FirstWord += DlzkaStrany; ZobrazAnSlovo(); FrmDrawForm(FrmGetActiveForm()); zpracovano = true; break; } if (udalost->data.ctlEnter.controlID == BtnUp ) // OK { FirstWord -= DlzkaStrany; FirstWord = (FirstWord < 0 ? 0 : FirstWord); ZobrazAnSlovo(); FrmDrawForm(FrmGetActiveForm()); zpracovano = true; break; } default: break; } return zpracovano; } Boolean ObslIDFormularList (EventPtr udalost) { EventType event; Boolean zpracovano = false; switch(udalost->eType) { case frmOpenEvent: ZobrazAnSlovo(); FrmDrawForm(FrmGetActiveForm()); zpracovano = true; break; case penUpEvent: if (StavAppl == 0) StavAppl = 1; else { if ((udalost->screenX > 2) & (udalost->screenX < 140)) { Int16 Riadok = udalost->screenX; if ((Riadok > AnTopPos) & (Riadok < MaxYPos)) { StavAppl = 2; SelRecordDetail = (Riadok - AnTopPos) / VyskaRiadka; FrmGotoForm(IDFormularPreklad); zpracovano = true; break; } } } case ctlSelectEvent: if (udalost->data.ctlEnter.controlID == bCancel ) // Cancel { event.eType = appStopEvent; EvtAddEventToQueue (&event); zpracovano = true; break; } if (udalost->data.ctlEnter.controlID == BtnDn ) // Delete { FirstWord += DlzkaStrany; ZobrazAnSlovo(); FrmDrawForm(FrmGetActiveForm()); zpracovano = true; break; } if (udalost->data.ctlEnter.controlID == BtnUp ) // OK { FirstWord -= DlzkaStrany; FirstWord = (FirstWord < 0 ? 0 : FirstWord); ZobrazAnSlovo(); FrmDrawForm(FrmGetActiveForm()); zpracovano = true; break; } break; default: break; } return zpracovano; } Boolean UdalostFormularPredvData (EventPtr udalost) { EventType event; Boolean zpracovano = false; switch(udalost->eType) { case frmOpenEvent: fld_UpdateDBPredvolby(); FrmDrawForm(FrmGetActiveForm()); zpracovano = true; break; case ctlSelectEvent: if (udalost->data.ctlEnter.controlID == bDelete ) // Delete { event.eType = appStopEvent; EvtAddEventToQueue (&event); zpracovano = true; break; } if (udalost->data.ctlEnter.controlID == bOk ) // OK { Mpdb_Add(&DBPredvolby); FrmGotoForm(IDFormularPredvolbyItems); zpracovano = true; break; } if (udalost->data.ctlEnter.controlID == bCancel ) // Cancel { rec_Cancel(&DBPredvolby); FrmGotoForm(IDFormularPredvolbyItems); zpracovano = true; break; } break; default: break; } return zpracovano; } Boolean UdalostIDFormularPredvolbyItems (EventPtr udalost) { EventType event; Boolean zpracovano = false; switch(udalost->eType) { case frmOpenEvent: MainViewTableInit(); FrmDrawForm(FrmGetActiveForm()); zpracovano = true; break; case ctlSelectEvent: if (udalost->data.ctlEnter.controlID == bItemsClose ) // Close app { event.eType = appStopEvent; EvtAddEventToQueue (&event); zpracovano = true; break; } if (udalost->data.ctlEnter.controlID == bItemsNew ) // New item { NullDBPredvolby(&RUnPackPredvolby); pdb_New (&DBPredvolby); FrmGotoForm(FormularPredvData); lLastRecord = pdb_RecNo (&DBPredvolby); zpracovano = true; break; } zpracovano = true; break; default: break; } return zpracovano; } void MainViewTableInit(void) { FormPtr frm; TablePtr tableP; Int16 numRows; Int16 i; frm = FrmGetActiveForm(); tableP = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, ItemsTBID)); numRows = TblGetNumberOfRows (tableP); for (i = 0; i < numRows; i++) { TblSetItemStyle(tableP, i, 0, numericTableItem); TblSetItemInt(tableP, i, 0, i); TblSetItemStyle(tableP, i, 1, textTableItem); TblSetItemInt(tableP, i, 1, i); TblSetItemStyle(tableP, i, 2, textTableItem); TblSetItemInt(tableP, i, 2, i); } for (i = 0; i < 3; i++) TblSetColumnUsable(tableP, i, true); TblSetLoadDataProcedure(tableP, 1, (TableLoadDataFuncPtr)CustomLoadItem); TblSetLoadDataProcedure(tableP, 2, (TableLoadDataFuncPtr)CustomLoadItem); } Err CustomLoadItem (void * table, Int16 row, UInt16 column, Boolean editing, MemHandle * textH, UInt16 * textOffset, UInt16 * textAllocSize, FieldPtr fld) { char* VyslStr; UnPackCisloItemType RUnPackRec; MemHandle recordH; CisloItemPtr MRec; if (row < pdb_RecNo (&DBPredvolby)) { recordH = DmQueryRecord (DBPredvolby.DBHandle, row); ErrFatalDisplayIf ((! recordH), "Record not found"); MRec = (CisloItemPtr) MemHandleLock (recordH); UnPackPredvolby(&RUnPackRec, MRec); } else { NullDBPredvolby(&RUnPackRec); StrCopy(RUnPackRec.AnSlovo, "**"); StrCopy(RUnPackRec.SlSlovo[1], "**"); }; if (column == 1) { *textAllocSize = StrLen(RUnPackRec.AnSlovo); // one for null terminator *textH = MemHandleNew(*textAllocSize + 1); VyslStr = MemHandleLock(*textH); StrCopy(VyslStr, RUnPackRec.AnSlovo); MemHandleUnlock(*textH); } if (column == 2) { *textAllocSize = StrLen(RUnPackRec.SlSlovo[1]); // one for null terminator *textH = MemHandleNew(*textAllocSize + 1); VyslStr = MemHandleLock(*textH); StrCopy(VyslStr, RUnPackRec.SlSlovo[1]); MemHandleUnlock(*textH); } *textOffset = 0; return 0; } void Zmen (char * newValue) { MemHandle myRecord = DmGetRecord(DBPredvolby.DBHandle, 1); CisloItemType *s = MemHandleLock(myRecord); CisloItemPtr nilP=0; DmWrite(s, (UInt32)&nilP->AnSlovo, &newValue, sizeof(newValue)); DmWrite(s, (UInt32)&nilP->SlSlovo[1], &newValue, sizeof(newValue)); MemHandleUnlock(myRecord); DmReleaseRecord(DBPredvolby.DBHandle, 1, true); } //--------------------------------------------------------------------------- Err pdb_Open(DBType *dbPP, char * MBASE_NAME, UInt32 MBASE_ID) { LocalID ID; dbPP->DBName = MBASE_NAME; dbPP->DBID = MBASE_ID; dbPP->DBHandle = NULL; dbPP->ACur = 0; dbPP->State = 0; ID = DmFindDatabase ( 0, MBASE_NAME); if (ID==0) if (DmCreateDatabase ( 0, MBASE_NAME, MBASE_ID, 'DATA', false)) ErrDisplay("PDB Create Error"); ID = DmFindDatabase ( 0, MBASE_NAME); dbPP->DBHandle = DmOpenDatabase ( 0, ID, dmModeReadWrite); if (!dbPP->DBHandle) { ErrDisplay("PDB Open Error"); return (1); } else { dbPP->State = 1; } return (0); } //--------------------------------------------------------------------------- void pdb_Close(DBType *dbPP) { DmCloseDatabase (dbPP->DBHandle); } //--------------------------------------------------------------------------- char * MStrCopy (char * source) { char * Nchar; Nchar = MemPtrNew (sizeof(source) + 1); StrCopy(Nchar, source); return (Nchar); } void UnPackPredvolby(UnPackCisloItemType* RUnPack, CisloItemPtr RPack) { UInt8 i; char* s; s = (char*)RPack; NullDBPredvolby(RUnPack); StrCopy(RUnPack->AnSlovo, s); s += StrLen(s) + 1; for(i = 0; (i <= MaxSlSlov) & (StrLen(s) > 0); i++) { StrCopy(RUnPack->SlSlovo[i], s); s += StrLen(s) + 1; } } void PackPredvolby (UnPackCisloItemPtr RUnPack, MemHandle RPack) { UInt16 offset = 0; UInt8 i; CisloItemPtr recordP; UInt16 RLen = StrLen(RUnPack->AnSlovo) + 1; for(i = 0; (i <= MaxSlSlov) & (StrLen(RUnPackPredvolby.SlSlovo [i]) > 0); ++i) RLen += StrLen(RUnPack->SlSlovo[i]) + 1; if (MemHandleResize (RPack, RLen) == 0) { recordP = MemHandleLock (RPack); offset = 0; DmStrCopy (recordP, offset, (char*)RUnPack->AnSlovo); offset += StrLen(RUnPack->AnSlovo) + 1; for (i = 0; (i <= MaxSlSlov) & (StrLen(RUnPack->SlSlovo[i]) > 0); ++i) { DmStrCopy (recordP, offset, (char*)RUnPack->SlSlovo[i]); offset += StrLen(RUnPack->SlSlovo[i]) + 1; } MemHandleUnlock (RPack); } } // ---------------------------------------------- void Mpdb_Add(DBType *dbPP) { UInt16 cur; MemHandle recordH; dbPP->ACur = pdb_RecNo(dbPP); cur = (UInt16)dbPP->ACur; cur += 1; recordH = DmNewRecord(dbPP->DBHandle, &cur, 100); PackPredvolby (&RUnPackPredvolby, recordH); (UInt16)dbPP->ACur = cur; } static void NullDBPredvolby(UnPackCisloItemType* RUnPack) { UInt8 i; StrCopy(RUnPack->AnSlovo, ""); for(i = 0; i <= MaxSlSlov; ++i) StrCopy(RUnPack->SlSlovo [i], ""); }; // ---- create some test data static void InitDBPredvolby(void) { MemHandle newRecH; CisloItemPtr newRec; CisloItemPtr nilP=0; if (pdb_RecNo(&DBPredvolby) == 0) { NullDBPredvolby(&RUnPackPredvolby); StrCopy((char*)&RUnPackPredvolby.AnSlovo, "do"); StrCopy((char*)&RUnPackPredvolby.SlSlovo[0], "robiť"); StrCopy((char*)&RUnPackPredvolby.SlSlovo[1], "pripraviť"); StrCopy((char*)&RUnPackPredvolby.SlSlovo[2], "urobiť"); Mpdb_Add(&DBPredvolby); NullDBPredvolby(&RUnPackPredvolby); StrCopy((char*)&RUnPackPredvolby.AnSlovo, "join"); StrCopy((char*)&RUnPackPredvolby.SlSlovo[0], "pridať"); StrCopy((char*)&RUnPackPredvolby.SlSlovo[1], "pripojiť"); Mpdb_Add(&DBPredvolby); NullDBPredvolby(&RUnPackPredvolby); StrCopy((char*)&RUnPackPredvolby.AnSlovo, "do"); StrCopy((char*)&RUnPackPredvolby.SlSlovo[0], "robiť"); StrCopy((char*)&RUnPackPredvolby.SlSlovo[1], "pripraviť"); StrCopy((char*)&RUnPackPredvolby.SlSlovo[2], "urobiť"); Mpdb_Add(&DBPredvolby); NullDBPredvolby(&RUnPackPredvolby); StrCopy((char*)&RUnPackPredvolby.AnSlovo, "join"); StrCopy((char*)&RUnPackPredvolby.SlSlovo[0], "pridať"); StrCopy((char*)&RUnPackPredvolby.SlSlovo[1], "pripojiť"); Mpdb_Add(&DBPredvolby); } } void StrRecFromFrm (char * RField, UInt16 Obj) { char * ptr; if (FldGetTextLength (GetObjectPtr(Obj)) > 0) { ptr = FldGetTextPtr (GetObjectPtr(Obj)); StrCopy(RField, ptr); } else { StrCopy(RField, " "); } } Int16 PopupRecFromFrm (UInt16 Obj) { return (LstGetSelection(GetObjectPtr(Obj))); } static void rec_UpdateDBPredvolby(void) { char s[30]; UInt8 i; if (FldDirty (GetObjectPtr(fldTown)) || FldDirty (GetObjectPtr(fldPredvolba)) || FldDirty (GetObjectPtr(fldTyp))) { StrRecFromFrm (RUnPackPredvolby.Town, fldTown); StrRecFromFrm (RUnPackPredvolby.Number, fldPredvolba); StrRecFromFrm (s, fldTyp); i = (UInt8)StrAToI (s); RUnPackPredvolby.Type = i; if (DBPredvolby.State == 1) pdb_Add(&DBPredvolby, &RPredvolby, sizeof(RPredvolby)); else pdb_Update(&DBPredvolby, &RPredvolby, sizeof(RPredvolby)); DBPredvolby.State = 0; } } void StrFrmFromRec (char * RField, UInt16 Obj) { FieldPtr fld; int len; fld = GetObjectPtr (Obj); len = FldGetTextLength(fld); FldDelete (fld, 0, len); FldInsert (fld, RField, StrLen(RField)); FldSetDirty (fld, false); } void PopupFrmFromRec (Int16 RField, UInt16 Obj, UInt16 ObjPopup) { FieldPtr fld; char * SText; ListPtr list = GetObjectPtr (Obj); LstSetSelection (list, RField); SText = LstGetSelectionText (list, RField); fld = GetObjectPtr (ObjPopup); FldSetTextPtr (fld, SText); } //--------------------------------------------------------------------------- static void fld_UpdateDBPredvolby(void) { char s[30]; StrFrmFromRec (RUnPackPredvolby.Town, fldTown); StrFrmFromRec (RUnPackPredvolby.Number, fldPredvolba); PopupFrmFromRec (RUnPackPredvolby.Type, TypeID, PTType); StrIToA (s, RPredvolby.Type); StrFrmFromRec (s, fldTyp); } // ---------------------------------------------- UInt32 pdb_RecNo(DBType *dbPP) { return (DmNumRecords (dbPP->DBHandle)); } // ---------------------------------------------- void pdb_Update(DBType *dbPP, void * Record, UInt32 size) { Err err=0; MemPtr ptr; MemHandle mem; mem = DmGetRecord (dbPP->DBHandle, dbPP->ACur); ptr = MemHandleLock (mem); err = DmWrite(ptr, 0, Record, size); ErrFatalDisplayIf(err, "pdb_Update"); MemHandleUnlock(mem); DmReleaseRecord(dbPP->DBHandle, dbPP->ACur, true); } // ---------------------------------------------- void rec_Cancel(DBType *dbPP) { dbPP->State = 0; } // ---------------------------------------------- void pdb_Add(DBType *dbPP, void * Record, UInt32 size) { Err err = 0; MemHandle h; MemPtr ptr; UInt16 cur; dbPP->ACur = pdb_RecNo(dbPP); cur = (UInt16)dbPP->ACur; h = DmNewRecord (dbPP->DBHandle, &cur, size); ptr = MemHandleLock(h); err = DmWrite(ptr, 0, Record, size); ErrFatalDisplayIf(err, "pdb_Add"); MemPtrUnlock(ptr); DmReleaseRecord(dbPP->DBHandle, dbPP->ACur, true); } // ---------------------------------------------- void pdb_New(DBType *dbPP) { dbPP->State = 1; } //--------------------------------------------------------------------------- void pdb_Get(DBType *dbPP, void * Record, UInt32 size) { MemPtr ptr; MemHandle mem; if (pdb_RecNo(dbPP)==0) return; mem = DmQueryRecord (dbPP->DBHandle, dbPP->ACur); if (mem==0) ErrDisplay("pdb_Get1"); ptr = MemHandleLock (mem); if (ptr==0) ErrDisplay("pdb_Get2"); MemMove(Record, ptr, size); MemHandleUnlock(mem); //DmReleaseRecord(BASE_HANDLE, BASE_CURR, true); } //--------------------------------------------------------------------------- void pdb_SetRow(DBType *dbPP, UInt32 Pos) { dbPP->ACur = Pos; } --------PalmOS.h-------------- #define MaxSlSlov 20 #define DlzkaStrany 10 #define MaxYPos AnTopPos + VyskaRiadka * DlzkaStrany typedef struct { char * DBName; UInt32 DBID; DmOpenRef DBHandle; UInt32 ACur; UInt8 State; } DBType; typedef struct { char AnSlovo [50]; char SlSlovo [MaxSlSlov] [50]; } UnPackCisloItemType; typedef UnPackCisloItemType* UnPackCisloItemPtr; static UnPackCisloItemType RUnPackPredvolby; typedef struct { char * AnSlovo; char * SlSlovo [MaxSlSlov]; } CisloItemType; typedef CisloItemType * CisloItemPtr; static DBType DBPredvolby; static CisloItemType RPredvolby; static void InitDBPredvolby(void); static void rec_UpdateDBPredvolby(void); static void fld_UpdateDBPredvolby(void); static void NullDBPredvolby(UnPackCisloItemType* RUnPack); Err pdb_Open(DBType *dbPP, char * MBASE_NAME, UInt32 MBASE_ID); void pdb_Close(DBType *dbPP); UInt32 pdb_RecNo(DBType *dbPP); void pdb_Add(DBType *dbPP, void * Record, UInt32 size); void pdb_Update(DBType *dbPP, void * Record, UInt32 size); void rec_Cancel(DBType *dbPP); void pdb_New(DBType *dbPP); void pdb_Get(DBType *dbPP, void * Record, UInt32 size); void pdb_SetRow(DBType *dbPP, UInt32 Pos); char * MStrCopy (char * source); void PackPredvolby (UnPackCisloItemPtr RUnPack, MemHandle RPack); void UnPackPredvolby(UnPackCisloItemPtr RUnPack, CisloItemPtr RPack); void Mpdb_Add(DBType *dbPP);