home *** CD-ROM | disk | FTP | other *** search
- program list;
- {
- Programer : Steve Nelson
- Date : 12-27-84
-
- This program is a file lister. The file name may be put on the
- command line, but if it is not on command line the program will
- prompt the user for the file name.
- Example:
- list list.pas or just list
-
- If the file name is not specified on the command line the program
- will also let the user change an Epson printer's setup to give
- compresed type or emphasized type.
-
- This program is to be compiled with the TURBO PASCAL compiler. If
- other compiler is used you may have to change the way the command
- line parameter is obtained, and the function copy which is used in
- the program.
- }
- const
- MAXPG = 55;
- FORMFEED = ^L;
- BLANK = ' ';
-
-
- type
- linetype = string[128];
- filetype = string[14];
-
- var
- param : string[120] absolute cseg:$0080;
- count, pgcount, pg, n : integer;
- infile : filetype;
- line : linetype;
- fil_var : text;
- param_found : boolean;
-
- procedure printer;
- const
- EMPH = ^['E';
- COMP = ^O;
- TOF = ^L;
- BLANK = ' ';
- BS = ^H;
-
- var
- command : char;
- quit : boolean;
- i : integer;
-
- begin
- quit := false;
- clrscr;
- for i:=1 to 10 do
- writeln;
- writeln(BLANK:15,'E -- Emphasized');
- writeln(BLANK:15,'C -- Compress');
- writeln(BLANK:15,'T -- Top of Form');
- writeln(BLANK:15,'Q -- Quit');
- writeln;
- write('Enter command: ');
- while not quit do begin
- read(command);
- command := upcase(command);
- case command of
- 'E' : writeln(lst,EMPH);
- 'C' : writeln(lst,COMP);
- 'T' : writeln(lst,TOF);
- 'Q' : quit := true
- else
- write (BS,' ',BS);
- end; { end case }
- write(BS, ' ',BS);
- end; { end while }
- clrscr;
- end; { end printer }
-
- function com_line (var infile:filetype) : boolean;
- var
- n, l, i : integer;
-
- begin
- l := length(param);
- n := 0;
- repeat
- n := n + 1;
- until (n >= l) or (param[n] <> BLANK);
- if (l-n) <= 0 then begin
- infile := BLANK;
- com_line := false;
- end
- else begin
- infile := copy(param,n,l-n+1);
- com_line := true;
- end;
- end;
-
- procedure page (pg : integer; infile : filetype; var pgcount : integer);
- var
- i, n : integer;
-
- begin
- pgcount := 0;
- writeln (lst,FORMFEED);
- for i:=1 to 2 do
- writeln (lst);
- write (lst,' ',infile);
- write (lst,BLANK:55);
- writeln (lst,'page ',pg:3);
- writeln (lst);
- writeln (lst);
- end;
-
- begin { Start main program }
- param_found := com_line(infile);
- if (not param_found) then begin
- write ('Enter file name: ');
- readln (infile);
- printer;
- end;
- assign (fil_var,infile);
- reset (fil_var);
- pg := 1;
- count := 0;
- pgcount := 0;
- writeln (lst);
- writeln (lst);
- writeln (lst,BLANK:30,infile);
- writeln (lst);
- writeln (lst);
- while not eof(fil_var) do begin
- readln(fil_var,line);
- count := count + 1;
- pgcount := pgcount + 1;
- if pgcount >= MAXPG then begin
- pg := pg + 1;
- page (pg, infile, pgcount);
- end;
- writeln (lst,' ',line);
- end;
- writeln (lst,formfeed);
- end.
-