
Problem sending Control Codes To Printer In Delphi 4
Quote:
> cls
> print "EPSON TEST PROGRAM FOR CASH DRAWER"
> LPRINT "THIS IS AN EPROM TEST"
> LPRINT "OPENS THE CASH DRAWER"
> LPRINT " "
> LPRINT
> CHR$(27)+CHR$(112)+CHR$(0)+CHR$(25)+CHR$(250)+CHR$(27)+CHR$(67)+CHR$(52)+CHR
> $(0)+CHR$(27)+CHR$(117)+CHR$(0)
> CLOSE
> STOP
> Please help me. How do you send control codes in Delphi 4 to the printer and
> have them treated as control codes.
If you want to do the same as the Basic code above, then it will
be something like this:
procedure TfrmNewPay.OpenCashDrawer;
var
f : TextFile;
begin
if (frmSales.sCashDrawerString = '') or (frmSales.iCashDrawer = -1)
then Exit;
AssignFile(f, 'LPT1');
Rewrite(f);
Writeln(f,
chr(27)+chr(112)+chr(0)+chr(25)+chr(250)+chr(27)+chr(67)+chr(52)+chr(0)+chr(
27)+chr(117)+chr(0));
CloseFile(f);
With that example the printing is done in the old DOS style, and all
the Esc-commands will go to the printer. But you can't use anything
related to Windows Printing System. So Printer.PrinterIndex to select
the printer etc. are useless.
As someone suggested, PassThrough printing, using WINAPI Escape
(ExtEscape) function is another way to make Esc sequences to go
through to the printer.
Markku Nevalainen