home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1998 February / PCOnline_02_1998.iso / filesbbs / dos / dbget390.exe / DBASEGET.MEX < prev    next >
Encoding:
Text File  |  1996-08-10  |  24.5 KB  |  799 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // File: dBaseGet.mex
  4. //
  5. // Version: 3.90
  6. //
  7. // Desc: Tool zum Lesen ein dBase Datei
  8. //
  9. // Copyright 1996 by Carsten Nau
  10. //
  11. //
  12. // Basierend auf den REXX-Scripts von Thomas Borrmann
  13. // Ebenfalls habe ich mir Anregungen in den Scripts von Kurt Vogelsaenger
  14. // geholt.
  15. //////////////////////////////////////////////////////////////////////////////
  16.  
  17. #include <max.mh>
  18.  
  19. #define DBF_PATH "C:\\AREAS\\DATEN\\"   // hier liegen die Datenbanken
  20. #define MISC_PATH "C:\\MAX\\MISC\\"     // Dein Misc-Pfad
  21. #define MaxRc    4000                   // = max. Anzahl der Datensätze
  22. #define Debug    False                  // fuer Testzwecke  auf True setzen
  23.  
  24. // Strings für Erweiterte Zeichencodes
  25.  
  26. // Doorway Modus
  27. #define CRSR_UP        18432
  28. #define CRSR_DOWN      20480
  29. #define CRSR_LEFT      19712
  30. #define CRSR_RIGHT     19200
  31. #define HOME           18176
  32. #define END            20224
  33. #define PG_UP          18688
  34. #define PG_DOWN        20736
  35. #define ENTER          124
  36. #define ESC            27
  37.  
  38. // Non-Doorway Modus
  39. #define _UP            'H'
  40. #define _DOWN          'R'
  41. #define _LEFT          'V'
  42. #define _RIGHT         'N'
  43. #define _HOME          'A'
  44. #define _PGUP          'I'
  45. #define _PGDOWN        'P'
  46. #define _END           'L'
  47. #define _ESC           'E'
  48.  
  49. // Vordergrund und Hintergrund | nur Vordergrund
  50. // ----------------------------+----------------
  51. // 0 schwarz                   | 8 dunkelgrau
  52. // 1 blau                      | 9 hellblau
  53. // 2 grüen                     | a hellgruen
  54. // 3 cyan                      | b hellcyan
  55. // 4 rot                       | c hellrot
  56. // 5 magenta                   | d hellmagenta
  57. // 6 braun                     | e gelb
  58. // 7 grau                      | f weiss
  59. //
  60. //                          ┌─ Hintergrund-Farbe
  61. //                          │┌ Vordergrund-Farbe (Schrift)
  62. #define Farbe1   "\x16\x01\x17" // = Feldname
  63. #define Farbe2   "\x16\x01\x1f" // = Inhalt
  64. #define Farbe3   "\x16\x01\x1e" // = Datum und Nr. von Ges.
  65. #define Farbe4   "\x16\x01\x30" // = Copyright
  66. #define Farbe5   "\x16\x01\x70" // = Meldungen
  67. #define Farbe6   "\x16\x01\x7e" // = Hotkey in Meldung
  68. #define Farbe7   "\x16\x01\x4e" // = Feld, Inhalt
  69. #define Farbe8   "\x16\x01\x1f" // = Hintergrund und Schrift (standart)
  70. #define Farbe9   "\x16\x01\x4e" // = Taste
  71. #define Farbe10  "\x16\x01\x4f" // = Hotkey Taste
  72. #define Farbe11  "\x16\x01\x1f" // = Browser Feldinhalt
  73. #define Farbe12  "\x16\x01\x3f" // = Browser Feldinhalt Balken
  74. #define Farbe13  "\x16\x01\x1e" // = Text vom Datensatz
  75.  
  76. #define BlkGr    16             // = max. Zeilen per Seite
  77.  
  78. char: nonstop;
  79.  
  80. unsigned long: RcCnt;                               // Anzahl der Einträge
  81. long: BlkNrM;
  82. unsigned int: RcLen, HdrLen;
  83. string: buf, date, DoorBase, FileName;
  84. int: fd, fdt, RxDBF_Cnt, RxDBFBrowseMax, TextBase;
  85. array [1..BlkGr] of string: RxDBF_Name;             // Feldname
  86. array [1..BlkGr] of string: RxDBF_Inhalt;           // Feldinhalt
  87. array [1..BlkGr] of char: RxDBF_Type;               // Feldtyp
  88. array [1..BlkGr] of unsigned int: RxDBF_Off;        // Feldoffset
  89. array [1..BlkGr] of char: RxDBF_Len;                // Feldlänge
  90. array [1..BlkGr] of char: RxDBF_Dec;                // davon Dezimalstellen
  91. array [0..MaxRc] of long: TextOffset;               // Textposition
  92.  
  93. /////////////////////////////////////////////////////////////////
  94. string gotoxy(int: row, int: col)
  95.  {
  96.   string: seq;
  97.   seq[1] := 22;
  98.   seq[2] := 8;
  99.   seq[3] := row+1;
  100.   seq[4] := col+1;
  101.   return seq;
  102.  }
  103.  
  104. //////////////////////////////////////////////////////////////////////////
  105. // RxInitDBF: Datei <Filename> oeffnen und Header lesen.                //
  106. // Bei Misserfolg wird 'Fehler: <Fehlertext>' zurueckgegeben            //
  107. //////////////////////////////////////////////////////////////////////////
  108.  
  109. string RxInitDBF()
  110. {
  111. int: jahr, i, offs;
  112. unsigned char: zahl1, zahl2, zahl3, zahl4, Len, Dec, Type;
  113. string: dBRec, Name;
  114.  
  115. i:=0;
  116. offs:=1;
  117.  
  118.     IF (fileexists(DBF_PATH+FileName+".dbf"))
  119.         {
  120.         fd := open(DBF_PATH+FileName+".dbf",IOPEN_READ);
  121.         read(fd,dBRec,32);
  122.         if (dBRec[1] <> 4 and dBRec[1] <> 3)
  123.             {
  124.             log("!Fehler: keine dBaseIII- oder dBaseIV- Datei");
  125.             return "Fehler: keine dBaseIII- oder dBaseIV- Datei";
  126.             }
  127.         else
  128.             {
  129.             jahr := dBRec[2];
  130.             IF (jahr < 80)
  131.                 jahr:=jahr+2000;
  132.             else
  133.                 jahr:=jahr+1900;
  134.             date:=itostr(dBRec[4])+"."+itostr(dBRec[3])+"."+itostr(jahr);
  135.             zahl1:=dBRec[5];
  136.             zahl2:=dBRec[6];
  137.             zahl3:=dBRec[7];
  138.             zahl4:=dBRec[8];
  139.             RcCnt:=(zahl4*16777216)+(zahl3*65536)+(zahl2*256)+zahl1;
  140.             zahl1:=dBRec[9];
  141.             zahl2:=dBRec[10];
  142.             HdrLen:=(zahl2*256)+zahl1+1;
  143.             zahl1:=dBRec[11];
  144.             zahl2:=dBRec[12];
  145.             RcLen:=(zahl2*256)+zahl1;
  146.             start:
  147.             i:=i+1;
  148.             seek(fd,i*32,SEEK_SET);
  149.             read(fd,dBRec,32);
  150.             IF (dBRec[1] = 13)
  151.                 {
  152.                 if(RxDBF_Name[i-1]="DOORBASE")
  153.                    {
  154.                    RxDBF_Cnt:=i-1;
  155.                    TextBase:=1;
  156.                    }
  157.                 else
  158.                    {
  159.                    RxDBF_Cnt:=i;
  160.                    TextBase:=0;
  161.                    }
  162.                 return "OK";
  163.                 }
  164.             RxDBF_Name[i]:=strtrim(substr(dBRec,1,11)," ");
  165.             RxDBF_Type[i]:=dBRec[12];
  166.             RxDBF_Len[i]:=dBRec[17];
  167.             RxDBF_Dec[i]:=dBRec[18];
  168.             RxDBF_Off[i]:=offs;
  169.             offs:=offs+RxDBF_Len[i];
  170.             goto start;
  171.             }
  172.         }
  173.     ELSE
  174.         {
  175.         log("!Die Datei "+DBF_PATH+FileName+".dbf existiert nicht!");
  176.         return "Fehler: Datei nicht vorhanden";
  177.         }
  178. }
  179.  
  180.  
  181. /////////////////////////////////////////////////////////////////
  182. // RxGetDBFRec( Satznummer )                                   //
  183. // liest einen dBase-Dateisatz Satznummer und                  //
  184. // schreibt ihn in RxDBF_Inhalt[x]                             //
  185. // Wenn der Satz nicht existiert, wird der Dateistatus mit     //
  186. // Description zurueckgegeben                                  //
  187. /////////////////////////////////////////////////////////////////
  188.  
  189. void RxGetDBFRec(unsigned long: RcNr)
  190. {
  191. int: i;
  192. long: BytePos;
  193. string: dBRec;
  194. BytePos:= (RcNr-1) * RcLen + HdrLen;
  195. seek(fd,BytePos,SEEK_SET);
  196. read(fd,dBRec,RcLen);
  197. FOR (i:=1; i<RxDBF_Cnt; i:=i+1)
  198.     RxDBF_Inhalt[i]:=substr(dBRec, (RxDBF_Off[i]), RxDBF_Len[i]);
  199. IF(TextBase=1)
  200.     DoorBase:=substr(dBRec, (RxDBF_Off[RxDBF_Cnt]), RxDBF_Len[RxDBF_Cnt]);
  201. return;
  202. }
  203.  
  204. /////////////////////////////////////////////////////////////////
  205. // RxDBFSearch( string: suche, unsigned long: RcNr )           //
  206. // suchte in den dBase-Datensatze mit dem Inhalt von 'suche'   //
  207. // und gibt die Nummer zurück                                  //
  208. // Wenn der Satz nicht existiert, wird die Nummer Null zurück  //
  209. // gegeben.                                                    //
  210. /////////////////////////////////////////////////////////////////
  211. unsigned long RxDBFSearch(string: suche, unsigned long: RcNr)
  212. {
  213. unsigned long: BytePos;
  214. int: done;
  215. string: dBRec;
  216. DO
  217.   {
  218.   RcNr:=RcNr+1;
  219.   BytePos:= (RcNr-1) * RcLen + HdrLen;
  220.   seek(fd,BytePos,SEEK_SET);
  221.   read(fd,dBRec,RcLen);
  222.   done:=strfind(strupper(dBRec),strupper(suche));
  223.   } while(done<1 and RcNr<=RcCnt);
  224. If(done=0)
  225.     RcNr:=0;
  226. return RcNr;
  227. }
  228.  
  229. /////////////////////////////////////////////////////////////////
  230. string center(string: arg)
  231. {
  232.   arg:=strpad("",(80-strlen(arg))/2,' ')+arg;
  233.   arg:=strpad(arg,80,' ');
  234.   return arg;
  235. }
  236.  
  237. /////////////////////////////////////////////////////////////////
  238. void RxDBFPrint()
  239. {
  240. int: i;
  241. FOR (i:=1; i<RxDBF_Cnt; i:=i+1)
  242.     print(gotoxy(i+1,2),Farbe1,RxDBF_Name[i],": ",gotoxy(i+1,15),Farbe2,substr(RxDBF_Inhalt[i],1,64));
  243. }
  244.  
  245. /////////////////////////////////////////////////////////////////
  246. string RxDBFPrintBrowse(long: RcNr)
  247. {
  248. int: i;
  249. string: text;
  250. text:="";
  251. RxGetDBFRec(RcNr);
  252. for(i:=1; i<RxDBFBrowseMax; i:=i+1)
  253.     text:=text+RxDBF_Inhalt[i]+"│";
  254. return text;
  255. }
  256.  
  257. /////////////////////////////////////////////////////////////////
  258. void maske()
  259. {
  260. int: i;
  261. print (gotoxy(0,0),Farbe4,center("O N L I N E  -  D A T E N B A N K"));
  262. for(i:=2; i<BlkGr+4; i:=i+1)
  263.     print(gotoxy( i,0),Farbe8,"                                                                                ");
  264. print(gotoxy(BlkGr+3,0),Farbe8,"────────────────────────────────────────────────────────────────────────────────");
  265. print(gotoxy(BlkGr+4,0),Farbe8,"   Steuerung:                                                                   ");
  266. print(gotoxy(BlkGr+5,0),Farbe8,"                                                                                ");
  267. print (gotoxy(BlkGr+6,0),Farbe4,center("dBaseGET 3.90 (c) Carsten Nau 1996"));
  268. return;
  269. }
  270.  
  271. /////////////////////////////////////////////////////////////////
  272. void keybrowser()
  273. {
  274. nonstop:=1;
  275. print(gotoxy(BlkGr+4,0));
  276. display_file(MISC_PATH+"DBGET_K2",nonstop);  // DBGET_K2.MEC
  277. }
  278.  
  279. /////////////////////////////////////////////////////////////////
  280. void hauptkey()
  281. {
  282. nonstop:=1;
  283. print(gotoxy(BlkGr+4,0));
  284. display_file(MISC_PATH+"DBGET_K1",nonstop);  // DBGET_K1.MEC
  285. If(TextBase=1)
  286.    print(gotoxy(BlkGr+5,57),Farbe10," T",Farbe9,"ext "); // Hilfe
  287. print(gotoxy(BlkGr+2,1),Farbe3,"Datum der letzten Aenderung: ",date);
  288. }
  289.  
  290. /////////////////////////////////////////////////////////////////
  291. void RxDBFText(long:Offset, int: BlkNr, int: MaxZeile)
  292. {
  293. int: rc, cnt;
  294. string: Textzeile;
  295.  
  296. seek(fdt,Offset,SEEK_SET);
  297. for(cnt:=0; cnt<(BlkNr-1)*BlkGr; cnt:=cnt+1)
  298.     rc:=readln(fdt, Textzeile);
  299. for(cnt:=0; cnt<BlkGr; cnt:=cnt+1)
  300.     {
  301.     rc:=readln(fdt, Textzeile);
  302.     if(substr(Textzeile,1,1)="{" and substr(Textzeile,10,1)="}")
  303.         Textzeile:=substr(Textzeile,11,80);
  304.     if((BlkNr-1)*BlkGr+cnt<MaxZeile-2)
  305.         {
  306.         print(Farbe13,gotoxy(cnt+2,0),"                                                                                ");
  307.         print(Farbe13,gotoxy(cnt+2,0),Textzeile);
  308.         }
  309.     else
  310.         print(Farbe13,gotoxy(cnt+2,0),"                                                                                ");
  311.     }
  312. return;
  313. }
  314.  
  315. /////////////////////////////////////////////////////////////////
  316. void hauptmaske()
  317. {
  318. maske();
  319. print(gotoxy( 1,0),Farbe7,"  Feldname     Inhalt                                                           ");
  320. hauptkey();
  321. }
  322.  
  323. /////////////////////////////////////////////////////////////////
  324. void masketext()
  325. {
  326. maske();
  327. print(gotoxy( 1,0),Farbe7,"  Text                                                                          ");
  328. keybrowser();
  329. }
  330.  
  331. /////////////////////////////////////////////////////////////////
  332. void maskebrowser()
  333. {
  334. unsigned int: i;
  335. maske();
  336. print(gotoxy( 1,0),Farbe7,"                                                                                ");
  337. for(i:=1; i<RxDBFBrowseMax; i:=i+1)
  338.     print(gotoxy( 1,(RxDBF_Off[i]+i)-1),Farbe7,RxDBF_Name[i],gotoxy( 1,(RxDBF_Off[i+1]+i)-1),"│");
  339. keybrowser();
  340. print(gotoxy(BlkGr+2,1),Farbe3,"Datum der letzten Aenderung: ",date);
  341. }
  342.  
  343. /////////////////////////////////////////////////////////////////
  344. void RxDBFBrowse(long: RcNr)
  345. {
  346. int: BlkNr, i;
  347.  
  348. print(gotoxy(BlkGr+2,40),Farbe3,"/ Nr.",RcNr," von ",RcCnt,"     ");
  349. BlkNr:=(((RcNr-1)-((RcNr-1)%BlkGr))/BlkGr)+1;
  350. If (BlkNr<>BlkNrM)
  351.     {
  352.     BlkNrM:=BlkNr;
  353.     for(i:=1; i<=BlkGr; i:=i+1)
  354.         {
  355.         if ((BlkNr*BlkGr-BlkGr+i)<=RcCnt)
  356.             {
  357.             if (BlkNr*BlkGr-BlkGr+i=RcNr)
  358.                 print(Farbe12,gotoxy(i+1,0),">",RxDBFPrintBrowse(BlkNr*BlkGr-BlkGr+i));
  359.             else
  360.                 print(Farbe11,gotoxy(i+1,0)," ",RxDBFPrintBrowse(BlkNr*BlkGr-BlkGr+i));
  361.             }
  362.         else
  363.             print(gotoxy( i+1,0),Farbe8,"                                                                                ");
  364.         }
  365.     }
  366. Else
  367.     {
  368.     If(((RcNr-1)%BlkGr)>=1)
  369.         print(Farbe11,gotoxy((RcNr-1)%BlkGr+1,0)," ",RxDBFPrintBrowse(RcNr-1));
  370.     If(((RcNr-1)%BlkGr)+2<=BlkGr and RcNr<RcCnt)
  371.         print(Farbe11,gotoxy((RcNr-1)%BlkGr+3,0)," ",RxDBFPrintBrowse(RcNr+1));
  372.     print(Farbe12,gotoxy((RcNr-1)%BlkGr+2,0),">",RxDBFPrintBrowse(RcNr));
  373.     }
  374. }
  375.  
  376. /////////////////////////////////////////////////////////////////
  377. void TextBaseInit()
  378. {
  379. int: rc, done, zeile, ZeileCnt, RcNrH;
  380. long: TextOff, TextOffM;
  381. unsigned long: RcNr, found;
  382. string: Textzeile, Base;
  383. nonstop:=1;
  384.  
  385.     IF (fileexists(DBF_PATH+FileName+".txb"))
  386.         IF (fileexists(DBF_PATH+FileName+".txi"))
  387.             {
  388.             display_file(MISC_PATH+"DBGET_M3",nonstop);  // DBGET_M3.MEC
  389.             print(Farbe5,gotoxy(10,45),RcCnt);
  390.             fdt:=open(DBF_PATH+FileName+".txi",IOPEN_READ);
  391.             for(rc:=0; rc<=RcCnt; rc:=rc+1)
  392.                 {
  393.                 print(gotoxy(10,33),rc);
  394.                 zeile:=readln(fdt, Textzeile);
  395.                 TextOffset[rc]:=strtol(Textzeile);
  396.                 }
  397.             close(fdt);
  398.             }
  399.         else
  400.             {
  401.             fdt:=open(DBF_PATH+FileName+".txb",IOPEN_READ);
  402. //            log("!Bearbeite: "+DBF_PATH+FileName+".txb");
  403.             display_file(MISC_PATH+"DBGET_H1",nonstop);  // DBGET_H1.MEC
  404.             print(Farbe5,gotoxy(16,45),RcCnt);
  405.             DO
  406.             {
  407.                 TextOffM:=TextOff;
  408.                 TextOff:=tell(fdt);
  409.                 rc:=readln(fdt, Textzeile);
  410.                 done:=kbhit();
  411.                 ZeileCnt:=ZeileCnt+1;
  412.                 if(TextOffM<>TextOff and Debug=True)
  413.                     print(gotoxy(18,40),"Zeile: ",ZeileCnt);
  414.                 if(substr(Textzeile,1,1)="{" and substr(Textzeile,10,1)="}")
  415.                     {
  416.                     Base:=substr(Textzeile,2,8);
  417.                     RcNr:=RxDBFSearch(Base,0);
  418.                     if(RcNr<>0)
  419.                         {
  420.                         found:=found+1;
  421.                         print(gotoxy(16,33),found);
  422.                         RcNrH:=RcNr;
  423.                         TextOffset[RcNrH]:=TextOff;
  424.                         }
  425.                     }
  426.             }while(rc<>-1 and done=False);
  427.             close(fdt);
  428.             if(done=True)
  429.                 TextBase:=0;
  430.             else
  431.                 {
  432.                 fdt:=open(DBF_PATH+FileName+".txi",IOPEN_WRITE | IOPEN_CREATE);
  433.                 for(rc:=0; rc<=RcCnt; rc:=rc+1)
  434.                     writeln(fdt,ltostr(TextOffset[rc]));
  435.                 close(fdt);
  436.                 }
  437.             }
  438.     else
  439.         {
  440.         display_file(MISC_PATH+"DBGET_M1",nonstop);  // DBGET_M1.MEC
  441.         getch();
  442.         }
  443. hauptmaske();
  444. return;
  445. }
  446.  
  447. /////////////////////////////////////////////////////////////////
  448. long showtext(long: RcNr)
  449. {
  450. int: rc, done, RcNrH, BlkNr, BlkMax, MaxZeile, key, ext_key;
  451. char: keyhit;
  452. string: Textzeile;
  453. RcNrH:=RcNr;
  454. BlkNr:=1;
  455. nonstop:=1;
  456.  
  457.     IF (fileexists(DBF_PATH+FileName+".txb"))
  458.         {
  459.         fdt:=open(DBF_PATH+FileName+".txb",IOPEN_READ);
  460.         // Feststellen wie viele Blöcke und Zeilen der Text hat
  461.         seek(fdt,TextOffset[RcNrH],SEEK_SET);
  462.         rc:=readln(fdt, Textzeile);
  463.         MaxZeile:=1;
  464.         done:=False;
  465.         DO
  466.         {
  467.             rc:=readln(fdt, Textzeile);
  468.             MaxZeile:=MaxZeile+1;
  469.             if(substr(Textzeile,1,1)="{" and substr(Textzeile,10,1)="}")
  470.                 {
  471.                 done:=True;
  472.                 }
  473.         }while(done=False and rc>=0);
  474.         BlkMax:=(MaxZeile-(MaxZeile%BlkGr))/BlkGr+1;
  475.         masketext();
  476.         RxDBFText(TextOffset[RcNrH], BlkNr, MaxZeile);
  477.         done:=False;
  478.         // Steuerschleife
  479.         DO
  480.         {
  481.             key := input_ch(CINPUT_SCAN | CINPUT_NOCTRLC, Farbe1);
  482.             if (key=91)                            // Check auf erweiterte Tasten
  483.              {
  484.               ext_key := input_ch(CINPUT_SCAN,Farbe1);
  485.              }
  486.             if (key=CRSR_UP or ext_key=_UP or key=(int)'8'or key=PG_UP or ext_key=_PGUP or key=(int)'V' or key=(int)'9')
  487.              {
  488.               BlkNr:=BlkNr-1;
  489.               keyhit:=0;
  490.              }
  491.  
  492.             if (key=CRSR_DOWN or ext_key=_DOWN or key=(int)'2' or key=PG_DOWN or ext_key=_PGDOWN or key=(int)'N' or key=(int)'3')
  493.              {
  494.               BlkNr:=BlkNr+1;
  495.               keyhit:=0;
  496.              }
  497.  
  498.             if (key=HOME or ext_key=_HOME or key=(int)'7' or key=(int)'A')
  499.              {
  500.               BlkNr:=1;
  501.               keyhit:=0;
  502.              }
  503.  
  504.             if (key=END or ext_key=_END or key=(int)'1' or key=(int)'L')
  505.              {
  506.               BlkNr:=BlkMax;
  507.               keyhit:=0;
  508.              }
  509.  
  510.             if (key='?' or key=(int)'?')     // Taste "?"
  511.              {
  512.                 display_file(MISC_PATH+"DBGET_H2",nonstop);  // DBGET_H2.MEC
  513.                 getch();
  514.                 masketext();
  515.              }
  516.              if (key=ENTER)     // Taste "Enter"
  517.              {
  518.                 done:=True;
  519.              }
  520.              if (key='E' or key=(int)'E')     // Taste "E"
  521.              {
  522.                 RcNr:=0;
  523.                 done:=True;
  524.              }
  525.              IF (keyhit=0)
  526.                 {
  527.                 IF (BlkNr > BlkMax)
  528.                    BlkNr:=BlkMax;
  529.                 IF (BlkNr < 1)
  530.                    BlkNr:=1;
  531.                 keyhit:=1;
  532. //                print(Farbe1,gotoxy(19,0),"BlkNr: ",BlkNr," MaxZeile: ",MaxZeile," BlkMax: ",BlkMax);
  533.                 RxDBFText(TextOffset[RcNrH], BlkNr, MaxZeile);
  534.                 }
  535.         } while (done = False);
  536.         }
  537.     else
  538.         {
  539.         display_file(MISC_PATH+"DBGET_M1",nonstop);  // DBGET_M1.MEC
  540.         getch();
  541.         }
  542. close(fdt);
  543. return RcNr;
  544. }
  545.  
  546. /////////////////////////////////////////////////////////////////
  547. long browser( long: RcNr)
  548. {
  549. int: i, key, ext_key, done, BlkNr;
  550. char: keyhit;
  551. nonstop:=1;
  552.  
  553. // Steuerungsschleife
  554. maskebrowser();
  555. BlkNrM:=0;
  556. RxDBFBrowse(RcNr);
  557. keyhit:=1;
  558. DO
  559. {
  560.     key := input_ch(CINPUT_SCAN | CINPUT_NOCTRLC, Farbe1);
  561.     if (key=91)                            // Check auf erweiterte Tasten
  562.      {
  563.       ext_key := input_ch(CINPUT_SCAN,Farbe1);
  564.      }
  565.     if (key=CRSR_UP or ext_key=_UP or key=(int)'V' or key=(int)'8')
  566.      {
  567.       RcNr:=RcNr-1;
  568.       keyhit:=0;
  569.      }
  570.  
  571.     if (key=PG_UP or ext_key=_PGUP or key=(int)'9')
  572.      {
  573.       BlkNrM:=0;
  574.       RcNr:=RcNr-BlkGr;
  575.       keyhit:=0;
  576.      }
  577.  
  578.     if (key=CRSR_DOWN or ext_key=_DOWN or key=(int)'N' or key=(int)'2')
  579.      {
  580.       RcNr:=RcNr+1;
  581.       keyhit:=0;
  582.      }
  583.  
  584.     if (key=PG_DOWN or ext_key=_PGDOWN or key=(int)'3')
  585.      {
  586.       BlkNrM:=0;
  587.       RcNr:=RcNr+BlkGr;
  588.       keyhit:=0;
  589.      }
  590.  
  591.     if (key=HOME or ext_key=_HOME or key=(int)'7' or key=(int)'A')
  592.      {
  593.       BlkNrM:=0;
  594.       RcNr:=0;
  595.       keyhit:=0;
  596.      }
  597.  
  598.     if (key=END or ext_key=_END or key=(int)'1' or key=(int)'L')
  599.      {
  600.       BlkNrM:=0;
  601.       RcNr:=RcCnt;
  602.       keyhit:=0;
  603.      }
  604.  
  605.     if (key='?' or key=(int)'?')     // Taste "?"
  606.      {
  607.         display_file(MISC_PATH+"DBGET_H3",nonstop);  // DBGET_H3.MEC
  608.         getch();
  609.         maskebrowser();
  610.         BlkNrM:=0;
  611.         keyhit:=0;
  612.      }
  613.      if (key=ENTER)     // Taste "Enter"
  614.      {
  615.         done:=True;
  616.      }
  617.      if (key='E' or key=(int)'E')     // Taste "E"
  618.      {
  619.         RcNr:=0;
  620.         done:=True;
  621.      }
  622.      IF (keyhit=0)
  623.         {
  624.         IF (RcNr > RcCnt)
  625.            RcNr:=RcCnt;
  626.         IF (RcNr < 1)
  627.            RcNr:=1;
  628.         keyhit:=1;
  629.         RxDBFBrowse(RcNr);
  630.         }
  631. } while (done = False);
  632. return RcNr;
  633. }
  634.  
  635. /////////////////////////////////////////////////////////////////
  636. void main(string: File)
  637. {
  638. long: TempRcNr, RcNr, RcFound;
  639. int: i, key, ext_key, done;
  640. char: keyhit;
  641. string: rc, suche;
  642.  
  643. FileName:=File;
  644. nonstop:=1;
  645.  
  646.     log("#dBaseGet \'"+FileName+"\' Start");
  647.     rc:=RxInitDBF();
  648.     IF (substr(rc,1,6)="Fehler")
  649.         {
  650.         log("!"+DBF_PATH+FileName+".dbf: "+rc);
  651.         return;
  652.         }
  653.     else
  654.         {
  655.         RcNr:=1;
  656.         RxGetDBFRec(RcNr);
  657.         RxDBFBrowseMax:=2;
  658.         i:=1;
  659.         do
  660.           {
  661.           RxDBFBrowseMax:=RxDBFBrowseMax+RxDBF_Len[i]+1;
  662.           i:=i+1;
  663.           } while (RxDBFBrowseMax<80 and i<RxDBF_Cnt);
  664.         RxDBFBrowseMax:=i-1;
  665.         if(RxDBFBrowseMax<2)
  666.             RxDBFBrowseMax:=2;
  667.         hauptmaske();
  668.         If(TextBase=1)
  669.            {
  670.            log("#TextBase Format");
  671.            TextBaseInit();
  672.            }
  673.         print(gotoxy(BlkGr+2,40),Farbe3,"/ Nr.",RcNr," von ",RcCnt);
  674.         RxDBFPrint();
  675.         // Steuerungsschleife
  676.         DO
  677.             {
  678.             key := input_ch(CINPUT_SCAN | CINPUT_NOCTRLC, Farbe1);
  679.             if (key=91)                            // Check auf erweiterte Tasten
  680.              {
  681.               ext_key := input_ch(CINPUT_SCAN,Farbe1);
  682.              }
  683.             if (key=CRSR_RIGHT or ext_key=_RIGHT or key=(int)'V' or key=(int)'4' or key=CRSR_UP or ext_key=_UP or key=(int)'8' or key=(int)'-')
  684.              {
  685.               RcNr:=RcNr-1;
  686.               keyhit:=0;
  687.              }
  688.  
  689.             if (key=CRSR_LEFT or ext_key=_LEFT or key=(int)'N' or key=(int)'6' or key=CRSR_DOWN or ext_key=_DOWN or key=(int)'2' or key=(int)'+')
  690.              {
  691.               RcNr:=RcNr+1;
  692.               keyhit:=0;
  693.              }
  694.  
  695.             if (key=HOME or ext_key=_HOME or key=(int)'7' or key=(int)'A')
  696.              {
  697.               RcNr:=0;
  698.               keyhit:=0;
  699.              }
  700.  
  701.             if (key=END or ext_key=_END or key=(int)'1' or key=(int)'L')
  702.              {
  703.               RcNr:=RcCnt;
  704.               keyhit:=0;
  705.              }
  706.  
  707.             if (key='S' or key=(int)'S')
  708.              {
  709.               TempRcNr:=RcNr; //aktueller Record sichern
  710.               RcNr:=0;        // Record auf 0 setzen, damit die Suche immer am Anfang der Datei startet
  711.               display_file(MISC_PATH+"DBGET_M4",nonstop);  // DBGET_M4.MEC
  712.               print(Farbe5,gotoxy(12,23));
  713.               RcFound:=input_str(suche,INPUT_NLB_LINE|INPUT_NOCTRLC,0,36,"");
  714.               if (RcFound=0)
  715.                 {
  716.                     RcNr:=TempRcNr; // sofern Suchtring nicht gefunden wird, Ursprungsrecord wieder herstellen.
  717.                     display_file(MISC_PATH+"DBGET_M5",nonstop);  // DBGET_M5.MEC
  718.                     getch();
  719.                 }
  720.               else
  721.                 {
  722.                   RcFound:=RxDBFSearch(suche,RcNr);
  723.                   if(RcFound=0)
  724.                     {
  725.                     display_file(MISC_PATH+"DBGET_M2",nonstop);  // DBGET_M2.MEC
  726.                     getch();
  727.                     }
  728.                   else
  729.                     RcNr:=RcFound;
  730.                 }
  731.               hauptmaske();
  732.               keyhit:=0;
  733.              }
  734.  
  735.             if (key='W' or key=(int)'W')
  736.              {
  737.               RcFound:=RxDBFSearch(suche,RcNr);
  738.               if(RcFound=0)
  739.                 {
  740.                 display_file(MISC_PATH+"DBGET_M2",nonstop);  // DBGET_M2.MEC
  741.                 getch();
  742.                 }
  743.               else
  744.                 RcNr:=RcFound;
  745.               hauptmaske();
  746.               keyhit:=0;
  747.              }
  748.  
  749.             if (key='U' or key=(int)'U')
  750.              {
  751.               RcNr:=browser(RcNr);
  752.               if(RcNr=0)
  753.                   done:=True;
  754.               hauptmaske();
  755.               keyhit:=0;
  756.              }
  757.  
  758.             if (key='T' or key=(int)'T' and TextBase=1)
  759.              {
  760.               RcNr:=showtext(RcNr);
  761.               if(RcNr=0)
  762.                   done:=True;
  763.               hauptmaske();
  764.               keyhit:=0;
  765.              }
  766.  
  767.             if (key='?' or key=(int)'?')     // Taste "?"
  768.              {
  769.                 display_file(MISC_PATH+"DBGET_H4",nonstop);  // DBGET_H4.MEC
  770.                 getch();
  771.                 hauptmaske();
  772.                 keyhit:=0;
  773.              }
  774.  
  775.             if (key='E' or key=(int)'E')     // Taste "E"
  776.              {
  777.               done:=True;
  778.               keyhit:=0;
  779.              }
  780.  
  781.             IF (RcNr > RcCnt)
  782.                 RcNr:=RcCnt;
  783.             IF (RcNr < 1)
  784.                 RcNr:=1;
  785.             IF (keyhit=0)
  786.                 {
  787.                 keyhit:=1;
  788.                 print(gotoxy(BlkGr+2,40),Farbe3,"/ Nr.",RcNr," von ",RcCnt,"     ");
  789.                 RxGetDBFRec(RcNr);
  790.                 RxDBFPrint();
  791.                 }
  792.         } while (done = False);
  793.     }
  794.     close(fd);
  795.     print("\f");
  796.     log("#dBaseGet Ende");
  797. }
  798.  
  799.