home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 1: Collection A / 17Bit_Collection_A.iso / files / 1124.dms / 1124.adf / sources_pcq / newimprimante.p < prev    next >
Text File  |  1991-04-15  |  2KB  |  137 lines

  1. Program PRINTFILE;
  2.  
  3.  
  4. {$I "pcq:Include/DOS.i"}
  5. {$I "pcq:Include/Ports.i"}
  6. {$I "pcq:Include/Parameters.i"}
  7. {$I "pcq:Include/StringLib.i"}
  8. const
  9.     nbretotale = 69;
  10. TYPE
  11.  
  12. var
  13.  
  14.  
  15.     IMPTR         : string;
  16.     InputFileName      : String;
  17.     PAGE        : String;
  18.     npage        : String;
  19.     para        : String;
  20.     I,lpage        : Integer;
  21.     lsource,ldest    : Integer;
  22.     p,long,long1    : integer;
  23.     nbligne        : integer;
  24.     nbpage        : integer;
  25.     Infile        : FileHandle;
  26.     Inptr        : FileHandle;
  27.     data        : byte;
  28.     source         : ^array [0..100000] of byte;
  29.     numerote    : boolean;
  30.  
  31.  
  32. procedure MET_PAGE;
  33.     begin
  34.     strcpy(PAGE,"\n\n\t\t\t\t\c1m-- ");
  35.     lpage:=IntToStr(NPAGE,nbpage);
  36.     Strncat(page,NPAGE,lpage);
  37.     strncat(page," --\c0m\n",7);
  38.     ldest:= DOSwrite(inptr,PAGE,strlen(page));
  39.     nbligne:=nbligne+3;
  40.     end;
  41.  
  42.  
  43. procedure VIDE;
  44.     begin
  45.     for p:=long downto nbligne-1 do 
  46.             ldest:=DOSwrite(Inptr,adr(data),1);    
  47.     nbligne:=1;
  48.     inc(nbpage);
  49.     end;
  50.  
  51.  
  52. procedure funct;
  53.     begin;
  54.     if not(numerote) then
  55.         begin
  56.         met_page;
  57.         vide;
  58.         end
  59.         else vide;
  60.     end;
  61.             
  62.  
  63.  
  64. procedure VIDE1;
  65.     begin
  66.     for p:= long1 downto nbligne+1 do ldest:= DOSwrite(Inptr,adr(data),1);
  67.     nbligne:=long1;
  68.     end;
  69.  
  70. begin
  71.     long:=nbretotale;
  72.     InputFileName := AllocString(60);
  73.     PAGE := AllocString(60);
  74.     IMPTR:=allocstring(8);
  75.     npage:=allocstring(4);
  76.     para:=allocstring(4);
  77.     IMPTR:="PRT:";
  78.     nbpage:=1;    
  79.     
  80.     GetParam(1, InputFileName);
  81.     GETPARAM(2, para);
  82.     numerote := strieq(para,"-p");
  83.     Infile := DOSOpen(InputFilename, ModeOldFile);
  84.     if not(numerote) then
  85.         long1:=long-8
  86.     else
  87.         long1:=long-5;
  88.  
  89.     if Infile<>nil then 
  90.  
  91.     begin
  92.     Inptr  := DOSOpen(IMPTR,ModeOldFile);
  93.     if inptr<>nil then
  94.         begin
  95.  
  96.         new(source);
  97.         lsource := dosRead(Infile,source,100000);
  98.         DOSClose(Infile);
  99.         i:=0;nbligne:=1;
  100.         while i<=lsource DO
  101.             begin
  102.             Data:=source^[i];
  103.             if data = 10 then inc(nbligne);
  104.             if data <> 12 then ldest:=DOSwrite(Inptr,adr(data),1)
  105.                 else
  106.                 begin
  107.                  data:=10;
  108.                  VIDE1;
  109.                  funct;
  110.                 End;
  111.             if nbligne=long1 then funct;
  112.                 
  113.             inc(i);
  114.             end;
  115.  
  116.         if data <> 12 then
  117.             begin
  118.             data:=10;
  119.             vide1;
  120.             funct;
  121.             end;
  122.  
  123.  
  124.         DOSclose(Inptr);
  125.         dispose(source);
  126.         end
  127.         else
  128.             begin
  129.             DOSclose(Infile);
  130.             writeln('error to open prt:');
  131.             end;
  132.  
  133.     end
  134.     else writeln('error file not found');
  135.   
  136. end.
  137.