Skip to main content

[archive] Hex Values

  • June 12, 2007
  • 4 replies
  • 0 views

[Migrated content. Thread originally posted on 08 June 2007]

Hi,

I need to send a control code to a device.
Done it before using
01 WS-OPEN-DRAWER PIC X(01) VALUE X"07".

edit:forgot to add this line to show how the thing was written to the device.
WRITE PRINT-LINE FROM WS-OPEN-DRAWER

But if I wanted to read the value from a file, how would you go about defining that then?

Thanks,

Shaun

4 replies

[Migrated content. Thread originally posted on 08 June 2007]

Hi,

I need to send a control code to a device.
Done it before using
01 WS-OPEN-DRAWER PIC X(01) VALUE X"07".

edit:forgot to add this line to show how the thing was written to the device.
WRITE PRINT-LINE FROM WS-OPEN-DRAWER

But if I wanted to read the value from a file, how would you go about defining that then?

Thanks,

Shaun
As long as the file is readable it should be just read it. Note however, if you want to send escape sequences to a printer, you typically won't want to perform a linefeed, so you should add WITH NO CONTROL to the WRITE statement.

[Migrated content. Thread originally posted on 08 June 2007]

Hi,

I need to send a control code to a device.
Done it before using
01 WS-OPEN-DRAWER PIC X(01) VALUE X"07".

edit:forgot to add this line to show how the thing was written to the device.
WRITE PRINT-LINE FROM WS-OPEN-DRAWER

But if I wanted to read the value from a file, how would you go about defining that then?

Thanks,

Shaun
Thanks,

What I've decided to do is let the user enter the values in a field which is then stored in a file.
We then use the ascii2hex routine to obtain the actual hexadecimal value to be sent to the cash drawer.

We also use -P SPOOLER-DIRECT

Works perfectly.

Shaun

[Migrated content. Thread originally posted on 08 June 2007]

Hi,

I need to send a control code to a device.
Done it before using
01 WS-OPEN-DRAWER PIC X(01) VALUE X"07".

edit:forgot to add this line to show how the thing was written to the device.
WRITE PRINT-LINE FROM WS-OPEN-DRAWER

But if I wanted to read the value from a file, how would you go about defining that then?

Thanks,

Shaun
Looks nice!

However, if I may. There is not really any reason to use ascii2hex. ascii2hex is a feature to generate a hex "string", the underlying value will be the same nevertheless.
Consider for instance formfeed. in ascii formfeed is value 12. the hex number of formfeed is 0x0c. Or in COBOL x"0c", the notion 0x or x"" in this case is just to identify the number system used, the "language" if you may. Just like you would say that £1 is the same as 12NOK or $2 (well may be not that bad, but close enough).

Say if you had:
77 MyChar PIC X.
77 MyNum REDEFINES MyChar PIC 99 COMP-X.
If you did:
MOVE x"0c" TO MyChar.
or
MOVE 12 TO MyNum.
or
MOVE x"0c" TO MyNum.

MyChar would in all instances be formfeed and the net effect be that a formfeed would be sent to the printer.

[Migrated content. Thread originally posted on 08 June 2007]

Hi,

I need to send a control code to a device.
Done it before using
01 WS-OPEN-DRAWER PIC X(01) VALUE X"07".

edit:forgot to add this line to show how the thing was written to the device.
WRITE PRINT-LINE FROM WS-OPEN-DRAWER

But if I wanted to read the value from a file, how would you go about defining that then?

Thanks,

Shaun
Thanks Gisle.

Much more simple approach.

Shaun