Příklady - Práce s uživatelskou databází

 const LenKey2  = 10;
 const wnMain   = 10;
 const cmDel    = 150;
 dim   F        : File;
 procedure Create;
   DBRewrite(F, "Test", 1, LenKey2);
   if _DBResult // 0 then
     _MsgBox(1, #3+"Nelze založit databázi", 0);
     Halt;
   endif
 endproc
 procedure Close;
   DBClose(F);
   _DBResult
 endproc
 procedure Fill;
   procedure Add (    Dta : String[50]);
     dim Key  : String[LenKey2];
     Key := _StrToCS(_UpperS(_RightSP(Dta, LenKey2)));
     DBAdd(F, _StrPut(Key, Dta))
   endproc
   call Add("Novotný")
   call Add("Emanuel")
   call Add("Apoštol")
   call Add("Čermák")
   call Add("Cubínek")
   call Add("Nohejl")
   call Add("Maxim")
   call Add("Oplt")
   call Add("Minář")
   call Add("Arnold")
   call Add("Barták")
   call Add("Jaroš")
 endproc
 procedure Dialog;
   dim RefNr : LongInt;
   dim Comm  : Word;
   WInit(wnMain, 0,0,17,17, "TEST", winMove, 0)
   Ins_DBBrowser (wnMain, 10, 01,01,18,09, $0000, F, RefNr, GetText, 0, 0);
   Switch("C+")
   Ins_DBString  (wnMain, 20, 01,10,18,11, $0001, 10, 2);
   Ins_Button    (wnMain,100, 02,12,17,14, "OK", cmOK, 1);
   Ins_Button    (wnMain,120, 02,14,17,16, "~S~maž", cmDel, 0);
   SelObject(wnMain, 20)
   WOpen(wnMain)
   repeat
     Comm := _Execute(wnMain);
     if Comm = cmDel then
       call Erase;
     endif
   until (Comm = cmOK) or (Comm = cmCancel);
   WDone(wnMain);
   return
   procedure FindFocused (dim RefNr : LongInt);
     dim Ident : LongInt;
     GetDataObj(wnMain, 10, Ident);
     if _DBFind(F, 1, RefNr, _LiToKey(Ident)) = False then
       _MsgBox(1, #3+"Věta nenalezena!", 0)
       RefNr := 0;
     endif
   endproc
   procedure Erase;
     dim Ident : LongInt;
     dim RefNr : LongInt;
     if _MsgBox(3, #3+"Mohu smazat větu na které je kurzor ?", 1) = cmYes then
       call FindFocused(RefNr);
       if RefNr // 0 then
         DBDelete(F, RefNr)
         call ReDrawLast;
       endif
     endif
   endproc
   procedure ReDrawLast;
     dim RefNr  : LongInt;
     dim KeyStr : String[MaxKeyLen];
     if _DBLast(F, 2, RefNr, KeyStr) then
       _DBGet(F, RefNr)
       SetDataObj(wnMain, 10, _GetLIResult(1));
     endif
   endproc
   GetText:
     SetResult(_Copy(_DBGet(F, RefNr), LenKey2+1, 50))
   return
 endproc
 call Create;
 call Fill;
 call Dialog;
 call Close;