home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1996 October / PCO_10.ISO / filesbbs / report20.arj / REPORT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-06-25  |  4.0 KB  |  142 lines

  1. PROGRAM Report;
  2.  
  3. {$A+,B-,F-,N-,O-,R-,S-,V-,I-,G+}
  4. {$M 10000,0,100000}
  5.  
  6. USES DOS,Crt,StrProcs;
  7.  
  8. CONST BufSize=$FFFF;
  9.       MaxDizLines=50;
  10.  
  11. LABEL NewEntry;
  12.  
  13. VAR i,AllZ,DizZ,Cntr:WORD;
  14.     Datei1,Datei2:TEXT;
  15.     DName1,DName2:PathStr;
  16.     Stichwort,Lesezeile:STRING;
  17.     Buffer:POINTER;
  18.     DizArray:ARRAY [1..MaxDizLines] OF STRING;
  19.  
  20. PROCEDURE BothOutput(Zeile:STRING);
  21. BEGIN
  22.   WriteLn(Zeile);
  23.   WriteLn(Datei2,Zeile);
  24. END;
  25.  
  26.  
  27. BEGIN
  28.   ClrScr;
  29.   WriteLn('┌──────╖ ┌─────╖ ┌─────╖ ┌──────╖ ┌──────╖ ┌─────╖  V2.0, Freeware-');
  30.   WriteLn('│ ╔══╕ ║ │ ╔═══╝ │ ╔═╕ ║ │ ╔══╕ ║ │ ╔══╕ ║ ╘═╕ ╔═╝  Report-Generator zur');
  31.   WriteLn('│ ╙──┘ ║ │ ╙─╖   │ ╙─┘ ║ │ ║  │ ║ │ ╙──┘ ║   │ ║    Dateisuche in Filelisten');
  32.   WriteLn('│ ╔═╕ ╔╝ │ ╔═╝   │ ╔═══╝ │ ║  │ ║ │ ╔═╕ ╔╝   │ ║');
  33.   WriteLn('│ ║ │ ╙╖ │ ╙───╖ │ ║     │ ╙──┘ ║ │ ║ │ ╙╖   │ ║    Thomas.Moenkemeier');
  34.   WriteLn('╘═╝ ╘══╝ ╘═════╝ ╘═╝     ╘══════╝ ╘═╝ ╘══╝   ╘═╝    FIDO: 2:2426/2240');
  35.   IF ParamCount=0 THEN BEGIN
  36.     WriteLn;
  37.     WriteLn('Syntax: REPORT <Quelldatei> <Zieldatei> <Stichwort>');
  38.     WriteLn;
  39.     WriteLn('Durchsucht <Quelldatei> nach einem <Stichwort> und schreibt alle');
  40.     WriteLn('Fundzeilen in <Zieldatei>. Das Stichwort wird, wenn nicht angegeben,');
  41.     WriteLn('im Dialog abgefragt. An die Zieldatei wird hinten REPORT.TXT angehängt.');
  42.     Halt(255)
  43.   END;
  44.   AllZ:=0;
  45.   LeseZeile:='';
  46.   Cntr:=0;
  47.   CheckEOF:=true;
  48.   GetMem(Buffer,BufSize);
  49.   SetTextBuf(Datei1,Buffer^,BufSize);
  50.   DName1:=ParamStr(1);
  51.   IF DName1='' THEN DName1:='M:\LIST\VCPHQALL.LST';
  52.   DName1:=FExpand(DName1);
  53.   WriteLn(#10+'Quelldatei: '+DName1);
  54.   DName2:=ParamStr(2);
  55.   IF DName2='' THEN DName2:=PathOnly(ParamStr(0))+'REPORT.DAT';
  56.   DName2:=FExpand(DName2);
  57.   WriteLn(#10+'Zieldatei: '+DName2);
  58.   Stichwort:=ParamStr(3);
  59.   IF Stichwort='' THEN BEGIN
  60.     Write(#10+'Bitte Stichwort eingeben :');
  61.     ReadLn(Stichwort);
  62.   END;
  63.   Stichwort:=FastUpper(Stichwort);
  64.   ASSIGN(Datei1,DName1);
  65.   RESET(Datei1);
  66.   ASSIGN(Datei2,DName2);
  67.   REWRITE(Datei2);
  68.   BothOutput('');
  69.   BothOutput('Suche nach "'+Stichwort+'" in der Datei "'+DName1+'" ergab:');
  70.   BothOutput('');
  71.   REPEAT
  72.     ReadLn(Datei1,Lesezeile);
  73.     INC(AllZ);
  74.     NewEntry:
  75.     IF (LeseZeile[1]<>#32) OR (LeseZeile[0]=#0) THEN BEGIN
  76.       DizZ:=1;
  77.       FillChar(DizArray,SizeOf(DizArray),#0);
  78.     END ELSE BEGIN
  79.       INC(DizZ);
  80.     END;
  81.     DizArray[DizZ]:=Lesezeile;
  82.     IF BOOLEAN(POS(Stichwort,FastUpper(LeseZeile))) THEN BEGIN
  83.       INC(Cntr);
  84.       FOR i:=1 TO DizZ DO BEGIN
  85.         BothOutPut(DizArray[i]);
  86.       END;
  87.       REPEAT
  88.         ReadLn(Datei1,Lesezeile);
  89.         INC(AllZ);
  90.         IF (LeseZeile[1]=#32) OR (LeseZeile[0]=#0) THEN BEGIN
  91.           BothOutput(LeseZeile);
  92.         END ELSE BEGIN     {schon ein neuer Eintrag}
  93.           BothOutput('');
  94.           GOTO NewEntry;
  95.         END;
  96.       UNTIL false;
  97.     END;
  98.   UNTIL (EOF(Datei1)) OR (KeyPressed);
  99.   CLOSE(Datei1);
  100.   BothOutput(STR0(Cntr,4)+' Dateien gefunden, '+STR0(AllZ,4)+' Zeilen durchsucht.');
  101.   IF (Cntr>0) THEN BEGIN
  102.     BothOutput('');
  103.     ASSIGN(Datei1,PathOnly(ParamStr(0))+'REPORT.TXT');
  104.     FileMode:=0;
  105.     RESET(Datei1);
  106.     IF DOSError=0 THEN REPEAT
  107.       ReadLn(Datei1,LeseZeile);
  108.       BothOutput(LeseZeile);
  109.     UNTIL EOF(Datei1);
  110.     BothOutput('');
  111.   END;
  112.   CLOSE(Datei1);
  113.   CLOSE(Datei2);
  114.   FreeMem(Buffer,BufSize);
  115. END.
  116.  
  117.  
  118.   REPEAT
  119.     ReadLn(Datei1,Lesezeile);
  120.     INC(Zeilen);
  121.     IF (LeseZeile[1]<>#32) THEN Start:=Zeilen;
  122.     IF BOOLEAN(POSBM(Stichwort,FastUpper(LeseZeile))) THEN BEGIN
  123.       INC(Zaehler);
  124.       CLOSE(Datei1);
  125.       ASSIGN(Datei1,DName1);
  126.       FileMode:=0;
  127.       RESET(Datei1);
  128.       FOR i:=1 TO Start DO ReadLn(Datei1,LeseZeile);
  129.       REPEAT
  130.         BothOutput(LeseZeile);
  131.         ReadLn(Datei1,Lesezeile);
  132.         INC(Zeilen);
  133.       UNTIL (LeseZeile[1]<>#32);
  134.       CLOSE(Datei1);
  135.       ASSIGN(Datei1,DName1);
  136.       FileMode:=0;
  137.       RESET(Datei1);
  138.       DEC(Zeilen);
  139.       FOR i:=1 TO Zeilen DO ReadLn(Datei1,LeseZeile);
  140.       BothOutput('');
  141.     END;
  142.