home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
m
/
mastlkt.zip
/
PRN-PART.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1986-10-06
|
4KB
|
156 lines
Program PrnPart; { Author: David Bennett / 10-06-86 }
{$G16384,P16384,D-} {To allow DOS redirection}
{
Compile and Run this code WITHOUT parameters to see description
of program. You may also look at the procedure Explain
}
Const
Whole = 1;
From = 2;
FromTo = 3;
LineFeed = ^L;
Type
AnyString = String[255];
Var
DiskFile : Text;
DiskName : String[64];
FirstPage,
LastPage : Integer;
PrnType : Integer;
Procedure Error(Message : AnyString);
Begin
WriteLn (CON,Chr(7));
WriteLn (CON,'An ERROR has occured ',Message);
Halt;
End;
Procedure IOCheck;
Begin
If IOResult > 0 Then Error('concerning the disk file '+DiskName);
End;
Procedure Explain;
Begin
WriteLn(CON,'* Program: PRN-PART.COM / Author: David Bennett / 10-06-86');
WriteLn(CON,'');
WriteLn(CON,'* Usage:');
WriteLn(CON,' PRN-PART <filespec> <first page> <last page>');
WriteLn(CON,'');
WriteLn(CON,'* Description:');
WriteLn(CON,' This program is to be used when you wish only to print part of a document');
WriteLn(CON,' file. If <last page> is not entered then printing will start and page');
WriteLn(CON,' <first page> and continue to the end of the document. If <first page> is');
WriteLn(CON,' not entered then file <filespec> will be printed in it''s entirety.');
WriteLn(CON,'');
WriteLn(CON,' A>PRN-PART WHATSUP.DOC 5 14 -> Will print pages 5 to 14 of file');
WriteLn(CON,' A:WHATSUP.DOC to the CONSOLE');
WriteLn(CON,'');
WriteLn(CON,' A>PRN-PART WHATSUP.DOC 21 > PRN -> Will print page 21 through the');
WriteLn(CON,' end of the file to the PRINTER');
WriteLn(CON,'');
WriteLn(CON,'*** A CONTRIBUTION OF $5.00 IS EXPECTED FOR GAINFUL USE OF THIS PROGRAM ***');
WriteLn(CON,'');
WriteLn(CON,' DAVID BENNETT');
WriteLn(CON,' 555 SUNSHINE ROAD');
WriteLn(CON,' KANSAS CITY, KANSAS 66115');
End;
Procedure OpenFiles;
Var
P : Integer;
Begin
If ParamCount = 0 Then Begin
ClrScr;
Explain;
Halt;
End;
If ParamCount > 0 Then Begin
DiskName := ParamStr(1);
PrnType := Whole;
End;
If ParamCount > 1 Then Begin
Val(ParamStr(2),FirstPage,P);
If P > 0 Then Error('with parameter 2 - '+ParamStr(2));
PrnType := From;
End;
If ParamCount > 2 Then Begin
Val(ParamStr(3),LastPage,P);
If P > 0 Then Error('with parameter 3 - '+ParamStr(3));
PrnType := FromTo;
End;
{$I-}
Assign(DiskFile,DiskName); IOCheck;
ReSet(DiskFile); IOCheck;
{$I+}
End;
Procedure PrintPage;
Var
LineCount : Integer;
FileChar : Char;
Begin
LineCount := 0;
Repeat
{$I-}
Read (DiskFile,FileChar); IOCheck;
{$I-}
Write(FileChar);
If EoLn(DiskFile) Then LineCount := LineCount + 1
Until (LineCount = 66) Or (FileChar = LineFeed) Or (Eof(DiskFile));
End;
Procedure GotoPage(PageNum : Integer);
Var
PageCount,
LineCount : Integer;
FileChar : Char;
Begin
PageCount := 1;
While PageNum > PageCount Do Begin
LineCount := 0;
Repeat
{$I-}
Read(DiskFile,FileChar); IOCheck;
{$I+}
If EoLn(DiskFile) Then LineCount := LineCount + 1;
Until (LineCount = 66) or (FileChar = LineFeed);
PageCount := PageCount + 1;
End;
End;
Var
PrnLoop : Integer;
Begin
OpenFiles;
Case PrnType of
Whole : While Not(Eof(DiskFile)) Do PrintPage;
From : Begin
GotoPage(FirstPage);
While Not(Eof(DiskFile)) Do PrintPage;
End;
FromTo : Begin
GotoPage(FirstPage);
For PrnLoop := 0 to LastPage - FirstPage Do
If Not(Eof(DiskFile)) Then PrintPage;
End;
Else Error('UnKnown');
End;
Close(DiskFile);
End.