home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPMHELP
/
PRINTHLP.LBR
/
PRINTHLP.PQS
/
PRINTHLP.PAS
Wrap
Pascal/Delphi Source File
|
2000-06-30
|
7KB
|
238 lines
{$V-}
Program Print_Help;
{ This program prints ZCPR V3.0 Help files on your printer. It will
strip off the eigth bit on help files processed by WordStar (TM
micropro) and recurse down the help tree to get all of the files.
If you define BF_On and BF_Off the portions of the help file in
standout mode (ie preceeded by ^A and trailed by ^B) will be printed
in with those two strings surrounding them.
Written By: Chuck McManis, August 16th 1985
Do with it what you will but don't ask me to support your changes.
}
Const
MaxHelp = 16;
{
(* I use these for the Mannesmann Tally 160L *)
BF_On = ^['[=z'; (* Turn on Enhanced Print (BoldFace) *)
BF_Off = ^['[>z'; (* Turn off Enhanced Print (Boldface) *)
Lst_Init = ^['[1y'^['[5y'; (* Initialization String *)
Lst_Exit = ^['[0y'^['[4w'; (* Deinitialization String *)
UL_On = ^['[4m'; (* Start Underlining Characters *)
UL_Off = ^['[0m'; (* Stop Underlining Characters *)
}
Lst_Init = ''; (* Initialization String *)
Lst_Exit = ''; (* Deinitialization String *)
BF_On = '';
BF_Off = '';
UL_On = '';
UL_Off = '';
Page_Length = 66; (* Define these for your printer *)
CanFormFeed = False;
Left_Margin = 4;
Bottom_Margin = 5;
TabWidth = 8;
Type
AnyString = String[255];
Var
Line_Buf, Header : AnyString;
Helpfiles : Array [0..MaxHelp] of Text;
Page_Num,Current_Line,CurFile, I, J, K : Integer;
HelpFileName, TempName : String[20];
HasType : Boolean;
{ Getfile will check the CP/M Command line to see if the user typed a filename
after the command that invoked us, if not a filename will be specifically
asked for. }
Procedure GetFile;
Begin
For I := 1 to 15 do HelpFileName[I] := ' ';
If (Mem[$80]=0) or (Mem[$80]=$FF) Then
Begin
Write('Enter Help file to print : ');
Readln(HelpFileName);
End
Else
Begin
For I := 1 to Mem[$80] Do
HelpFileName[I] := Chr(Mem[I+$80]);
HelpFileName[0] := Chr(Mem[$80]);
End;
Assign(HelpFiles[0],HelpFileName);
Reset(HelpFiles[0]);
Writeln('Printing Help file ',HelpFileName:Length(HelpFileName));
End; (* GetFile *)
{ This function does two things, first it checks to see if the input character
was a ^A (Boldface ON) or ^B (Boldface OFF) control, and if it is replace
it with the appropriate escape sequence. Second, if it is a <TAB> character
it inserts enough spaces to emulate the tab and throws the tab away.
}
Function Format(Our_String : AnyString) : AnyString;
Var
I, Column : Integer;
Tmp_string : AnyString;
New_Char : Char;
Begin
Column := 0;
Tmp_String := '';
For I := 1 to Length(Our_String) do
Begin
Case Our_String[I] of
^A : Tmp_String := Tmp_String + BF_On;
^B : Tmp_String := Tmp_String + BF_Off;
^I : Begin
Repeat
Tmp_String := Tmp_String + ' ';
Column := Column + 1;
Until ((Column Mod TabWidth) = 0);
End;
Else
Begin
Tmp_String := Tmp_String + Our_String[I];
Column := Column + 1;
End;
End; (* Case *)
End; (* For Loop *)
Format := Tmp_String;
End;
{ This routine gets data from the file. Since a lot of the help files have
been created using Wordstar (TM MicroPro) They have bit 7 set on some
characters. This can really confuse Turbo so this routine fills in for
what Readln should really be able to do. It gets single characters and
masks off Bit 7, then (if it detects a <CR>) it passes it on to the
main code.
}
Procedure GetLine(Var Line : AnyString);
Var
Next_Chr : Char;
Done : Boolean;
Begin
Line := '';
Done := False;
Repeat
Read(HelpFiles[CurFile],Next_Chr);
If Eoln(Helpfiles[CurFile]) Then
Begin
Readln(HelpFiles[CurFile]);
Done := True;
End;
Next_Chr := Chr(Ord(Next_Chr) And $7F);
If Next_Chr = ^M then
Begin
Done := True;
Read(HelpFiles[CurFile],Next_Chr); { Eat the Line feed }
End
Else
If (Next_Chr <> ^J) And (Next_Chr <> ^L) Then
Line := Line + Next_Chr;
Until Done or Eof(HelpFiles[CurFile]);
End;
{ Advance Printer to the Next Page. This actually advances the printer and
Prints the header. The header is composed of either the file name or the
latest information section that was processed. If you have set CanFormFeed
to FALSE above it will fake a form feed by printing enough <LF> characters
to make up a page.
}
Procedure Form_Feed;
Begin
If CanFormFeed Then
Writeln(LST,^L)
Else
While (Current_Line Mod Page_Length) <> 0 do
Begin
Writeln(LST);
Current_Line := Current_Line + 1;
End;
Current_Line := 4;
Writeln(LST);
Writeln(LST,' ':Left_Margin,Header,' ':60-(Length(Header)+Left_Margin),
'Page ',Page_Num:3);
Writeln(LST);
Writeln(LST);
Page_Num := Page_Num + 1;
End;
{ Print a line to the printer and add in the leftmargin if defined above. The
purpose of the left margin is to skip over holes in the paper that allow the
sheets to be stored in a 3 ring binder.
}
Procedure Print(Line : AnyString);
Begin
Writeln(LST,' ':Left_Margin,Line);
Current_Line := Current_Line + 1;
If (Current_Line Mod (Page_Length - Bottom_Margin)) = 0 Then Form_Feed;
End;
{ * * * * - - M A I N C O D E - - * * * * }
Begin
GetFile;
CurFile := 0;
Page_Num := 1;
Current_Line := 0;
Write(LST,Lst_Init);
Header := 'Helpfile ' + HelpfileName;
Form_Feed;
Repeat
If Eof(HelpFiles[CurFile]) Then
Begin
Close(HelpFiles[CurFile]);
CurFile := CurFile - 1;
If CurFile = -1 Then CurFile := 0;
End
Else
GetLine(Line_Buf);
Line_Buf := Format(Line_Buf);
If Length(Line_Buf) = 0 Then Print('')
Else
Begin
If Line_Buf[1] = ':' Then
Begin
J := 0;
For I := 2 to Length(Line_Buf) do
If (Line_Buf[I] = ':') And (J = 0) Then J := I;
If J <> 0 Then
Begin
CurFile := CurFile + 1;
HelpFileName := Copy(Line_Buf,J+1,20);
HasType := False;
For I := 1 to Length(HelpFileName) do
If HelpFileName[I] = '.' Then HasType := True;
If Not HasType Then HelpFileName := helpfilename + '.HLP';
Writeln('Opening file "',HelpFileName,'"');
Assign(HelpFIles[Curfile],HelpFIlename);
Reset(HelpFiles[CurFile]);
Header := 'Subfile ' + HelpFileName;
Form_Feed;
End (* If : J <> 0 *)
Else
Begin
Header := Copy(Line_Buf,2,40);
Print('');
Print(UL_On+Header+UL_Off);
Print('');
End; (* Else : Line_Buf[2] = ':' *)
End (* If Line_Buf[1] = ':' *)
Else
Begin
If Line_Buf <> ^L Then Print(Line_Buf);
End; (* Else *)
End; (* Else : Length > 0 *)
Until (CurFile = 0) And (Eof(HelpFIles[0]));
Writeln(LST,Lst_Exit);
End.