home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
PRINTING
/
PRINTPAS.ZIP
/
PRINTPAS.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1991-04-27
|
4KB
|
139 lines
{ PrintPas, a Pascal source file printer }
{ by Benjamin L. Combee }
{ Copyright 1991, Alpha-One Software }
{ -------------------------------------------------------------------
Features: Prints files a 8 lines per inch and 12 cpi to fit more
on a page, skips perferations on printer paper, indents lines to
allow for hole punching, prints header line and procedure and
function headings in boldface, accepts filename from either command
line or from user prompt.
------------------------------------------------------------------- }
PROGRAM PrintPas (INPUT, OUTPUT);
USES Printer;
CONST { Page specifics }
LinesPerPage = 88;
BottomMargin = 8;
CONST { Printer codes }
ResetPrn = #27 + '@';
SetElite = #27 + 'M';
Set8LPI = #27 + '0';
SetBold = #27 + 'G';
ResetBold = #27 + 'H';
FormFeed = #12;
TYPE
t_FileName = STRING [80];
{ -------------------------------------------------------------------
Banner prints a welcome message and copyright notice.
------------------------------------------------------------------- }
PROCEDURE Banner;
BEGIN
WriteLn;
WriteLn ('PrintPAS -- a Pascal source code printing program');
WriteLn ('by Benjamin L. Combee. Copyright 1991, Alpha-One Software.');
WriteLn;
END;
{ -------------------------------------------------------------------
GetFile either prompts for a filename, or accepts a command line
parameter. If there are more than one entry on the command line,
it ignores it and prompts for the file.
------------------------------------------------------------------- }
FUNCTION GetFile: t_FileName;
VAR
FileName: t_FileName;
BEGIN
IF ParamCount = 1 THEN
FileName := ParamStr (1)
ELSE
BEGIN
FileName := '';
WHILE (FileName = '') DO
BEGIN
Write ('Enter filename: ');
ReadLn (FileName);
END;
END;
GetFile := FileName;
END;
{ -------------------------------------------------------------------
PrintFile reads a file in line by line, keeping track of page
numbers, margins, and continuations. If it finds a Pascal reserved
word in the line, it will print the word in bold.
------------------------------------------------------------------- }
PROCEDURE PrintFile (FileName: t_FileName);
VAR
CurrentLine, CurrentPage: INTEGER;
TextLine: STRING [96];
T: Text;
BEGIN
{ Set to first line, first page }
CurrentLine := 1;
CurrentPage := 1;
{ Now, print the pages }
Assign (T, FileName);
Reset (T);
Write (Lst, ResetPrn, SetElite, Set8LPI);
WHILE NOT EOF (T) DO
BEGIN
IF CurrentLine = 1 THEN
BEGIN
Write (Lst, SetBold, ' (', FileName, ' p. ');
WriteLn (Lst, CurrentPage, ')', ResetBold);
END
ELSE IF (CurrentLine = 2) OR
(CurrentLine > (LinesPerPage - BottomMargin)) THEN
WriteLn (Lst)
ELSE
BEGIN
ReadLn (T, TextLine);
Insert (' ', TextLine, 1);
IF (Pos ('FUNCTION', TextLine) <> 0) OR
(Pos ('PROCEDURE', TextLine) <> 0) THEN
WriteLn (Lst, SetBold, TextLine, ResetBold)
ELSE
WriteLn (Lst, TextLine);
END;
Inc (CurrentLine);
IF CurrentLine > LinesPerPage THEN
BEGIN
CurrentLine := 1;
Inc (CurrentPage);
END;
END;
Write (Lst, FormFeed, ResetPrn);
Close (T);
END;
{ ------------------------------------------------------------------- }
BEGIN
Banner;
PrintFile (GetFile);
END.