sending hexadecimal control characters, how to?

Alex Tweedly alex at tweedly.net
Thu Dec 3 09:38:45 EST 2009


Peter Alcibiades wrote:
> Sarah, brilliant!  It is indeed a receipt printer.  So do you maybe know how 
> to do the next part?  In order to activate the paper cutter on it, one
> is supposed to do this to trigger the auto cutter drive:
>
> <ESC> “d” “0” or <ESC> “d” <0>
> (1B)H (64)H (30)H or (1B)H (64)H (00)H
> <ESC> “d” “1” or <ESC> “d” <1>
> (1B)H (64)H (31)H or (1B)H (64)H (01)H
>
> So do you have to convert some or all of this to ascii, and then
> put that into the text?  And if so how?
>
>   
You can do

   put baseConvert("1B", 16, 10) into t
   put numtochar(t) after theOutputString

for each character.

Note that what you have above is actually the same line repeated , i.e.

<ESC> “d” “0” or <ESC> “d” <0>
is the same as 
(1B)H (64)H (30)H or (1B)H (64)H (00)H

and 

<ESC> “d” “1” or <ESC> “d” <1>
is the same as
(1B)H (64)H (31)H or (1B)H (64)H (01)H



So (what I'd do :-) ...
   put numtochar(27) into cESC    -- ESC is ascii 27 is 1B(H)
then
   put cESC & "d0" after theOutputString  
or
   put cESC & "d1" after theOutputString  

-- Alex.



More information about the use-livecode mailing list