home *** CD-ROM | disk | FTP | other *** search
- PROGRAM CROSSPRINT; {Print document sideways}
-
- { Released to the Public Domain
- by Gary Bohn, 1985
- CROSSPRINT is written in TURBO PASCAL, Ver 2.0, for the Epson
- MX-80 printer with GRAFTRAX.
- CROSSPRINT prints text files sideways on the paper, thus al-
- lowing long lines (ie spreadsheets and PERT charts) to be printed
- as continuous lines (up to 255 characters/line). The left-to-right
- document is printed top-to-bottom on the paper so that the top of
- the document is printed to the right side of the printer. ASCII
- values in the file which are outside the range [32..127] are set
- to space (ASCII 32) before printing.
- The normal 5 x 9 matrix used for the character set becomes a
- 10 x 5 matrix. (One extra dot for interline spacing.) Only 5 of
- the 8 pins addressable by dot graphics are used. The paper is
- moved up by 2/216" to print "dots between dots" to form characters
- with angles (N, X, etc). The normal LF/CR sequence becomes a
- paper shift of 17/216".
- The low density graphics mode (480 dots/8" line) creates charac-
- ters slightly taller than the normal print mode. The pitch of the
- sideways characters is slightly less than 10 characters/inch.
- Printing is slow since the printer prints in only one direction and
- requires two passes for each character. The program does eliminate
- needless head movement by detecting the lowest line not containing
- a space.
- The file containing the character data base (XPRINT.FNT) must
- reside on the default disk drive.
- CROSSPRINT may be altered for other dot matrix printers by
- changing the printer graphics commands in Procedure Xprint.
- CROSSPRINT is self-prompting. Printing may be interrupted at
- any time with Cntl-C.
- }
- {$R+} {Set Range checking active}
- {$U+} {Allow Cntl-C interrupt at any time}
-
- CONST
- ClrScrn= #26; {Clear screen, ADM-3A terminal}
- Escape= #27;
- LineFeed= ^J;
- FormFeed= ^L;
- LinesPerPage= 48; {8.5" paper, 8" print line}
- MaxLength= 255; {Max of 255 characters per line}
- Printer= 'Epson MX-80';
- Reset= '@'; {Reset printer to power-on state (MX-80)}
-
- VAR
- Line: Array [1..LinesPerPage] of String[MaxLength];
- LineNo, LongLine, I, J: Byte;
- FilVar: Text;
- Resp: Char;
- Ltrs: Array[32..127, 1..20] of Byte;
-
- PROCEDURE GETFONT; {Read data base to create sideways letters}
-
- TYPE
- CharData= Record
- PinCode: 0..127;
- End; {CharData}
-
- VAR
- I, J: Byte;
- K: Integer;
- FontData: File of CharData;
- Letter: CharData;
- OK: Boolean;
-
- Begin
- Assign(FontData, 'XPRINT.FNT');
- Repeat
- {$I-} {Turn off I/O error handling}
- Reset(FontData);
- {$I+} {Turn it back on}
- OK:= (IOResult= 0); {Find file?}
- If Not OK Then
- Begin
- Writeln(LineFeed,'Can''t find file ''XPRINT.FNT'' on default drive.':63);
- Write(LineFeed, 'Press RETURN when ready. ':52);
- Readln(Resp);
- End; {If Not OK}
- Until OK;
-
- K:= 0;
- For I:= 32 to 127 Do {ASCII values from 32 to 127}
- For J:= 1 to 20 Do {20 bytes per character}
- Begin
- Seek(FontData, K);
- Read(FontData, Letter);
- Ltrs[I,J]:= Letter.PinCode;
- K:= K + 1;
- End; {For J ...}
- Close(FontData);
- End; {Procedure GetFont}
-
- PROCEDURE XPRINT; {Print sideways}
-
- VAR
- Ascii, I, J, K, L: Byte;
- DotPrint, HeadShift, LineSpace: String[4];
- NumDots, NumDot1, NumDot2, LastChar: Integer;
-
- Begin {Printer - Unique ---- Epson MX-80}
- HeadShift:= Escape + '3' + CHR(2); {Shift 2/216" for second pass}
- LineSpace:= Escape + '3' + CHR(17); {Shift 17/216" for next line}
-
- For I:= 1 to LongLine Do
- Begin
- LastChar:= 1; {Don't move head for spaces}
- While ((Line[LastChar][I] = ' ') And (LastChar < LinesPerPage)) Do
- LastChar:= LastChar + 1;
-
- { 60 dot/inch graphics & proper number of dots per pass
- Printer - Unique ---- Epson MX-80
- }
- NumDots:= 10 * (LinesPerPage - LastChar + 1); {10 Dots/Character}
- NumDot1:= NumDots Mod 256; {Need remainder}
- NumDot2:= NumDots Div 256; {Integer part}
- DotPrint:= Escape + 'K' + CHR(NumDot1) + CHR(NumDot2);
-
- For J:= 0 to 1 Do {Two passes per character}
- Begin
- Write(Lst, DotPrint); {Set printer for dot graphics}
- For L:= LinesPerPage DownTo LastChar Do
- Begin
- Ascii:= Ord(Line[L][I]);
- If Ascii > 127 Then Ascii:= Ascii - 128; {Don't want Bit 7}
- If Not (Ascii In [32..127]) Then Ascii:= 32;
- For K:= 1 to 10 Do {Print dots forming characters}
- Write(Lst, CHR(Ltrs[Ascii, K + J * 10]));
- End; {For L ...}
- Writeln(Lst, HeadShift); {Move head for second pass}
- End; {For J ...}
- Writeln(Lst, LineSpace); {Move head for next line}
- End; {For I ...}
- Write(Lst, FormFeed);
- End; {XPrint}
-
- PROCEDURE CLRPAGE; {Set array elements to 'Space'}
-
- VAR
- I, J: Byte;
-
- Begin
- For I:= 1 to LineNo Do
- For J:= 1 to LongLine Do
- Line[I][J]:= ' ';
- End; {ClrPage}
-
- PROCEDURE GETNAME; {Get name of file to be printed}
-
- VAR
- FileName, Newname: String[14];
- OK: Boolean;
-
- Begin
- Repeat
- Write('Enter name of file to be listed (ex: A:FileName.Ext): ');
- Readln(FileName);
-
- NewName:= ''; {Set FileName to uppercase}
- For I:= 1 to Length(FileName) Do
- NewName:= NewName + UpCase(Copy(FileName, I, 1));
- FileName:= NewName;
-
- Assign(FilVar, FileName);
- {$I-} {Turn off I/O error handling}
- Reset(FilVar);
- {$I+} {Turn it back on}
- OK:= (IOResult = 0); {Find File?}
- If Not OK Then
- Writeln(LineFeed, LineFeed, 'File ', FileName, ' not found.', LineFeed);
- Until OK;
-
- Writeln(ClrScrn, 'Printing file ', FileName, ' sideways.');
-
- End; {GetName}
-
- PROCEDURE READFILE; {Read lines from file to be printed}
-
- Begin
- LineNo:= 0;
- While ((LineNo < LinesPerPage) and (Not EOF(FilVar))) Do
- Begin
- LineNo:= LineNo + 1;
- Readln(FilVar, Line[LineNo]);
- End; {While LineNo < LinesPerPage and Not EOF}
-
- LongLine:= 0; {What is longest line?}
- For I:= 1 to LineNo Do
- If Length(Line[I]) > LongLine Then
- LongLine:= Length(Line[I]);
-
- End; {ReadFile}
-
- Begin
- Writeln(ClrScrn, 'CROSSPRINT':45);
- Writeln(Printer:(40 + Length(Printer) Div 2), LineFeed);
- LongLine:= MaxLength; {To initialize entire array to 'space'}
- LineNo:= LinesPerPage; {Ditto}
-
- GetFont; {Read sideways character data base}
- GetName; {Get name of file to be printed}
-
- Repeat
- ClrPage; {Clear array to 'space'}
- ReadFile; {Read lines from file}
- XPrint; {Print sideways}
- Until EOF(FilVar);
-
- Write(Lst, Escape, Reset); {Reset printer to power-on state.}
- Write(ClrScrn);
- End. {CrossPrint}