Re:How should I print ASCII Text in Delphi 2.
Richard Tan <Richard_...@workmail.com> wrote in article
<339437E9.7780E...@workmail.com>...
Quote
> Simon Grunbauer wrote:
> > I am writing a Label printing program in Delphi 2, attached to a label
> > printer via LPT1, which requires its instructions in the form of ASCII
> > text
> > to describe the label. I could not use the TPrinter object because it
> > sent
> > the text to Print Manager which printed the text in a graphic format,
> > and
> > not as ASCII text.
> > This code works fine, while the printer is connected and online.
[deletions]
Quote
> > printer is not connected, the first Writeln command causes the program
> > to
> > hang.
> > How do I overcome this problem, and am I doing this correctly or is
> > there a
> > better approach.
> > --
> > Simon Grunbauer
> > Sij...@Ozemail.com.au
> I think the reason your program hang is it is waiting for your printer
> to confirm on the print. Have you try the Try...Finally...End; command?
> I don't understand why you can't use TPrinter, it's much easer.
> Richard Tan
No, TRY ... FINALLY ... END does not work. Nor does the use of
IORESULT. I thought this problem had an easy answer, but after
30 minutes I had to move on.
TPrinter doesn't really work if you want to control the printer without
all the Windows overhead. For example, if for some reason you want
to send HPGL code to a HP LaserJet, you would need to follow this
same general approach.
In Delphi 1 BIOS interrupt 0x17 could have been used (see C code
below), but I don't think this will work in Delphi 2.
/* chkprt, EFG, 10/2/90, Turbo C++ */
#include <dos.h>
int main (void)
{
union REGS regs;
regs.h.ah = 0x02; /* request printer port status */
regs.x.dx = 0x0000; /* printer number 0..2 */
int86 (0x17, ®s, ®s); /* BIOS interrupt x17 */
printf ("printer status: dec %03d hex %02X\n",regs.h.ah,regs.h.ah);
return (regs.h.ah);
Simon, you still have a very interesting problem.
--
_________________________________________________
Earl F. Glynn EarlGl...@WorldNet.att.net
EFG Software 913/859-9557 Voice/Fax
Scientific/Engineering/Medical Applications
Overland Park, KS USA