home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug017.arc
/
PRINTCAT.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1979-12-31
|
9KB
|
230 lines
PROGRAM printcat;
{Program to print out the MAST.CAT with 4 files to the line.}
{The program needs to be on the same disk as the catalog. }
{ A D D I T I O N S }
{ ----------------- }
{1/2/86 removed unwanted variables and documented the }
{ lines. }
{2/2/86 padded extention to print left justified }
{ moved some assingments out of loop }
{ added procedure center }
LABEL
1;
CONST
ver = 'Ver 1.02';
topline = 'M A S T . C A T -- Printout. ';
by = 'Writen by Peter Billing.';
date = '2 - 2 - 1986';
TYPE
st80 = STRING[80];
VAR
Q : text; {Used to switch between Screen and Printer}
infile : text; {assigned to MAST.CAT }
line : STRING[60]; {read a line from the file }
heading : STRING[60]; {heading for each page. }
footnote : STRING[60]; {now many files printed }
topheading:STRING[50]; {Sign on heading }
filename : STRING[8]; {filename without extention }
fill : STRING[8]; {used to pad out filename to 8 characters }
test : STRING[4]; {check to see if matches ".ext" }
No : STRING[4]; {Number of files printed. }
diskno : STRING[3]; {the three digits of the disk name. }
ext : STRING[3]; {the three character extention. }
extention: string[3]; {the extention left justified }
ch : char; {a dummy char for general use. }
f : integer; {length of filename without extention }
i : integer; {general variable for use in loops }
j : integer; {counter for the number of files per line }
k : integer; {position of the start of the extention }
m : integer; {end of extention }
l : integer; {total length of whole "line" }
e : integer; {length of extention }
lineno : integer; {counts the number of lines printed }
printer : boolean; {is the printer being used }
diskdrive: boolean; {is the file being writen to disk }
PROCEDURE Device; {Q must be declared globaly as TEXT}
VAR Dev: char;
BEGIN
writeln('Which output device ? .. S<creen>, P<rinter> or F<ile> ? ');
REPEAT
read(kbd,dev);
dev := upcase(dev);
writeln(dev);
IF NOT (dev IN ['S','P','F'])
THEN
BEGIN
writeln;
writeln('An "S", "P" or "F" expected. Try again.');
END;
UNTIL dev IN ['S','P','F'];
CASE dev OF
'S' : assign(Q,'CON:');
'P' : BEGIN
assign(Q,'LST:');
printer := true;
END;
'F' : BEGIN
assign(Q,'PRINT'+ ext +'.CAT');
diskdrive := true;
END;
END; {CASE OF}
rewrite(Q);
END;{Procedure device}
PROCEDURE center(message : st80);
begin
writeln(q,message:40+(length(message) div 2));
end;
PROCEDURE center2(message : st80);
begin
write(q,message:40+(length(message) div 2));
end;
BEGIN
clrscr;
printer := false;
diskdrive := false;
extention := '';
ext := '';
fill := ' ';
assign(q,'CON:');
reset(q);
topheading := topline + ver;
center(topheading);
center(by);
center(date);
writeln;
writeln(' This program will print out the MAST.CAT with 4 files to the line.');
writeln(' The files can be displayed on the Screen, printed on a Printer or');
writeln(' written to a File. The File name will be "PRINText.CAT". The ext');
writeln(' will equal the extention you asked for.');
writeln(' There is no error checking for file names or disk space.');
writeln(' The program needs to be on the same disk as the catalog.');
writeln;
writeln(' You can enter a heading which will be printed on the top of each');
writeln(' page. Maximium length is 60 characters. There is only one line.');
writeln;
writeln(' When used with a printer the program will stop at the end of each');
writeln(' sheet and wait for the <RETURN> to be pressed. (I use single sheet.)');
writeln(' You will be prompted at this time.');
writeln;
center2('A to Abort. Any key to continue.');
read(KBD,ch);
if upcase(ch) = 'A' then goto 1;
assign(infile,'MAST.CAT');
reset(infile);
ext := '';
writeln;
write('What Extention do you want listed? Just the last 3 letters eg MWB ');
readln(ext);
e := length(ext);
FOR i := 1 TO e DO
ext[i] := upcase(ext[i]);
writeln('Looking for files *.',ext);
extention := ext + copy(fill,5,3-e); {left justify the extention}
writeln;
writeln('What Heading do wish ? Just press <RETURN> for no heading. ');
readln(heading);
device;
clrscr;
REPEAT {don't worry about the files between ( )}
read(infile,ch);
UNTIL ch = ')';
readln(infile); {put the pointer onto the next line}
j := 1; {no of files printed}
lineno := 0; {no of lines printed}
WHILE (NOT eof(infile)) DO
BEGIN
IF lineno MOD 55 = 0
THEN BEGIN
IF printer
THEN BEGIN
writeln('Press RETURN when printer is ready.':45);
readln(ch);
write(q,chr(27),chr(56));
END;
writeln(q); {v- put the heading in the center}
center(HEADING);
writeln(q);
FOR i := 1 TO 4 DO
write(q,' File name Disk');
writeln(q);
FOR i := 1 TO 4 DO
write(q,' No.');
writeln(q);
FOR i := 1 TO 78 DO
write(q,'-');
writeln(q);
write(q,' ');
lineno := lineno + 1;
END;
read(kbd); {able to stop program }
readln(infile,line); {read the next line }
k := pos('.',line); {find the first . }
m := pos(',',line);
test := copy(line,k+1,m-k-1); {read the length of ext}
IF test = ext {Test to see if are what we are looking for }
THEN BEGIN {if it is true them start work }
filename := copy(line,1,k-1); {filename is everything up to . }
f := length(filename); {find the length of the filename}
{So that all the names line up nicely they all need to be the }
{same length. To do that spaces are added to the end of the }
{filename. This is done by taking away the length of the }
{filename from a string of 8 blanks. The blanks left are }
{then added to the end of the filename making it 8 chars long }
filename := filename + copy(fill,1,8-f);
l := length(line); {find length of total line. }
{The Disk No is found by subtracting from the end of the line }
{the last three characters }
diskno := copy(line,l-2,3);
{print the filename some where.}
write(q,filename:8,'.',extention:3,diskno:4,' ');
IF j <> 0
THEN BEGIN
IF j MOD 4 =0
THEN BEGIN
writeln(q);
lineno := lineno + 1;
write(q,' ');
IF (lineno MOD 55 = 0) AND (printer)
THEN
BEGIN
writeln(q,chr(12));
FOR i := 1 TO 3 DO
write(chr(7));
END;
END;
END;
j := j + 1;
END;
END;
writeln(q);
str(j - 1,no);
footnote := 'There were ' + No + ' files with the extention ' + ext;
center(footnote);
IF printer
THEN BEGIN
writeln(q,chr(12));
FOR i := 1 TO 4 DO
write(chr(7));
END;
IF diskdrive
THEN close(q);
1:
END.