Board index » delphi » How to send Escape code to COM or LPT port?

How to send Escape code to COM or LPT port?

I need to send some escape codes to a printer and a POS display.
Here is my code fragment:

var ID: integer;
     code: array[0..2] of char;
begin
  ID := OpenComm('COM1', 1, 20); { a Point-of-Sale display with 20
characters per line }
  code[0] := chr(27); { ESCAPE }
  code[1] := chr($1C); { some funtion }
  code[2] := chr(2); { function parameters }
  WriteComm(ID, code, 3);
end;

When I tried this, nothing happened. However if I try sending only a single
code to the display,
it works. (e.g. WriteComm(ID, chr($1D), 1); { Clear display } )

Please help me to solve the above problems. Thanks very much.

Ken.

 

Re:How to send Escape code to COM or LPT port?


Quote
Ken wrote...

|I need to send some escape codes to a printer and a POS display.
|Here is my code fragment:
|
|var ID: integer;
|     code: array[0..2] of char;
|begin
|  ID := OpenComm('COM1', 1, 20); { a Point-of-Sale display with 20
|characters per line }
|  code[0] := chr(27); { ESCAPE }
|  code[1] := chr($1C); { some funtion }
|  code[2] := chr(2); { function parameters }
|  WriteComm(ID, code, 3);

Aahh...long time no see, the WIN16 COMM API. This call expects a
PChar.
If I remember correctly, you should do:
  WriteComm(ID, code[0], 3).....

If it still doesn't work, mail me.

|end;
|
|When I tried this, nothing happened. However if I try sending only a
single
|code to the display,
|it works. (e.g. WriteComm(ID, chr($1D), 1); { Clear display } )
|

regards,
Dirk Claessens
______________________________________________
Home   : <dirk.claess...@village.uunet.be>
Office : <dirk.claessens...@belgium.agfa.com>
"All programming is done with the glands.
 Logic is added later to tidy things up."
______________________________________________

Other Threads