What is the effortless way to convert Alphanumeric field to Binary

Any suggestion on effortless approach to change field format from A to B
when content and length are remain the same

Hi Nikolai;

First, an observation. For lengths le 4, e.g. B1-B4, binary is basically numeric. For format above B5, binary is basically alpha.

I haven’t played with this in awhile (will try to dig out an old Inside Natural article and send it to you), but my memory is that above A5 you should be able to simply change An to Bn.

Above B4 you can run into trouble if you have mixed format statements.

For example, the below works fine since I have B3.

1 #A (A3)
1 #B (B3)
1 #n (N3)
include aatitler
include aasetc
move ‘abc’ to #a #b
write 10t ‘=’ #a (em=h(5)) ‘=’ #b
move 123 to #a #n #b
write 10t ‘=’ #a (em=h(5)) ‘=’ #b ‘=’ #n (em=h(5))

PAGE #   1                    DATE:    14-10-24
PROGRAM: AB02                 LIBRARY: BOSTON01

     #A: 616263 #B: 616263
     #A: 313233 #B: 00007B #N: 313233

#B has the numeric value 7B in Hex which is, of course, 123 in decimal.

HOWEVER, if I change formats to

1 #A (A3)
1 #B (B5) /* now greater than 4
1 #n (N3)

I get the error message:

NAT0300 Operands are not data transfer compatible pointing to: move 123 to #a #n #b.

Operands are not data transfer compatible.
According to the format rules for data transfer,
the source operand cannot be assigned to the destination field.
For more information, see the Natural documentation,
topic ‘Rules for Arithmetic Assignment’.
Check program and correct error.

Actually, this is a bit strange. #B is now basically alpha, and, in general, I can move numeric to alpha. Take the #B away in the MOVE and the program works fine.

So, no guarantees, but you might be able to get away with just changing, for example, A10 to B10.

HOWEVER, beware the problem shown above.

What exactly are you trying to accomplish by changing A to B. If you want to simply be able to do something like
compute #a = #n +3, this is legal in Natural.