Title: | Printing binary files with Eloquence |
Document: | 942427460 |
Author: | Roland Genske <rhg@marxmeier.com> |
Keywords: | eloq,print,binary |
Printing binary files with Eloquence
This is a small Eloquence program which sends a binary
file to the printer. It is especially useful on the
Windows platform where binary pass-through from COMMAND "!..."
always fails:
PRINTER IS 5,WIDTH(-1),TRANSPARENT
CALL Copy_bin("c:/temp/binary.prn")
PRINTER IS 8
STOP
!
SUB Copy_bin(Fname$)
INTEGER B(1:512)
DIM Buf$[1024]
!
XASSIGN #1 TO Fname$;OTHR
Nbytes=SIZE(1)
Nwords=Nbytes DIV 2
WHILE Nwords>512
READ #1;B(*)
Nwords=Nwords-512
PACK USING F;Buf$
F: PACKFMT B(*)
PRINT Buf$;
END WHILE
! Read remaining words
IF Nwords THEN
REDIM B(1:Nwords)
READ #1;B(*)
PACK USING F;Buf$
PRINT Buf$[1;Nwords*2];
END IF
! Read odd byte
IF Nbytes MOD 2 THEN
ON END #1 GOTO Eof
READ #1;Buf$
Eof: IF NOT LEN(Buf$) THEN Buf$=CHR$(10)
PRINT Buf$;
END IF
SUBEND
Changes 2005-10-05: The previous version could cause an ERROR 16 if
Nwords was zero (for example, the file size was 1024).
Changes 2017-02-24: The previous version could lose the last byte
of a file if the file size is odd and the last byte is CHR$(10).
|