home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / LIST.ZIP / LIST.PAS
Encoding:
Pascal/Delphi Source File  |  1986-11-07  |  3.5 KB  |  144 lines

  1. program list;
  2. {
  3.   Programer : Steve Nelson
  4.   Date      : 12-27-84
  5.  
  6.   This program is a file lister.  The file name may be put on the
  7.   command line, but if it is not on command line the program will
  8.   prompt the user for the file name.
  9.   Example:
  10.             list list.pas   or just  list
  11.  
  12.   If the file name is not specified on the command line the program
  13.   will also let the user change an Epson printer's setup to give
  14.   compresed type or emphasized type.
  15.  
  16.   This program is to be compiled with the TURBO PASCAL compiler. If
  17.   other compiler is used you may have to change the way the command
  18.   line parameter is obtained, and the function copy which is used in
  19.   the program.
  20. }
  21. const
  22.    MAXPG = 55;
  23.    FORMFEED = ^L;
  24.    BLANK = ' ';
  25.  
  26.  
  27. type
  28.    linetype = string[128];
  29.    filetype = string[14];
  30.  
  31. var
  32.    param                  : string[120] absolute cseg:$0080;
  33.    count, pgcount, pg, n  : integer;
  34.    infile                 : filetype;
  35.    line                   : linetype;
  36.    fil_var                : text;
  37.    param_found            : boolean;
  38.  
  39. procedure printer;
  40. const
  41.     EMPH = ^['E';
  42.     COMP = ^O;
  43.     TOF  = ^L;
  44.     BLANK = ' ';
  45.     BS    = ^H;
  46.  
  47. var
  48.     command : char;
  49.     quit    : boolean;
  50.     i       : integer;
  51.  
  52. begin
  53.     quit := false;
  54.     clrscr;
  55.     for i:=1 to 10 do
  56.         writeln;
  57.     writeln(BLANK:15,'E -- Emphasized');
  58.     writeln(BLANK:15,'C -- Compress');
  59.     writeln(BLANK:15,'T -- Top of Form');
  60.     writeln(BLANK:15,'Q -- Quit');
  61.     writeln;
  62.     write('Enter command: ');
  63.     while not quit do begin
  64.         read(command);
  65.         command := upcase(command);
  66.         case command of
  67.             'E' : writeln(lst,EMPH);
  68.             'C' : writeln(lst,COMP);
  69.             'T' : writeln(lst,TOF);
  70.             'Q' : quit := true
  71.         else
  72.             write (BS,' ',BS);
  73.         end; { end case }
  74.         write(BS, ' ',BS);
  75.     end; { end while }
  76.     clrscr;
  77. end; { end printer }
  78.  
  79. function com_line (var infile:filetype) : boolean;
  80. var
  81.     n, l, i               : integer;
  82.  
  83. begin
  84.     l := length(param);
  85.     n := 0;
  86.     repeat
  87.        n := n + 1;
  88.     until (n >= l) or (param[n] <> BLANK);
  89.     if (l-n) <= 0 then begin
  90.        infile := BLANK;
  91.        com_line := false;
  92.     end
  93.     else begin
  94.        infile := copy(param,n,l-n+1);
  95.        com_line := true;
  96.     end;
  97. end;
  98.  
  99. procedure page (pg : integer; infile : filetype; var pgcount : integer);
  100. var
  101.    i, n                   : integer;
  102.  
  103. begin
  104.    pgcount := 0;
  105.    writeln (lst,FORMFEED);
  106.    for i:=1 to 2 do
  107.       writeln (lst);
  108.    write (lst,'   ',infile);
  109.    write (lst,BLANK:55);
  110.    writeln (lst,'page ',pg:3);
  111.    writeln (lst);
  112.    writeln (lst);
  113. end;
  114.  
  115. begin  { Start main program }
  116.    param_found := com_line(infile);
  117.    if (not param_found) then begin
  118.        write ('Enter file name: ');
  119.        readln (infile);
  120.        printer;
  121.    end;
  122.    assign (fil_var,infile);
  123.    reset (fil_var);
  124.    pg := 1;
  125.    count := 0;
  126.    pgcount := 0;
  127.    writeln (lst);
  128.    writeln (lst);
  129.    writeln (lst,BLANK:30,infile);
  130.    writeln (lst);
  131.    writeln (lst);
  132.    while not eof(fil_var) do begin
  133.       readln(fil_var,line);
  134.       count := count + 1;
  135.       pgcount := pgcount + 1;
  136.       if pgcount >= MAXPG then begin
  137.          pg := pg + 1;
  138.          page (pg, infile, pgcount);
  139.       end;
  140.       writeln (lst,'      ',line);
  141.    end;
  142.    writeln (lst,formfeed);
  143. end.
  144.