Page 1 of 1

about c2x bulid-in function

PostPosted: Thu May 19, 2011 1:57 pm
by Pumpkin
hi,
i have some 2 questions about c2x function,as follow:

first:
say C2X('123') --------- F1F2F3
say C2X('123'X) ---------0123 (what does the x mean,how this result come out?)

Second:
num1 pix 999 comp-3 value 123.[num1 is part of a record in a ps file]
say C2X(num1) --------- 123F (pls, help explain the behind reason, how this result come out?)

thanks!

Re: about c2x bulid-in function

PostPosted: Thu May 19, 2011 2:24 pm
by enrico-sorichetti
imagine to see things vertically
c2x will just flatten things


'123'      fff      c2x('123')  ==> F1F2F3
           123

'123'x     02       c2x('123'x) ==> 0123
           13

as far as a packed number is the same concept
num1       123
num1       13       c2x(num1)   ==> 123F       
           2F

Re: about c2x bulid-in function

PostPosted: Fri May 20, 2011 11:03 am
by Pumpkin
thanks for reply!

Re: about c2x bulid-in function

PostPosted: Sat May 21, 2011 1:18 am
by Pedro
> what does the x mean,how this result come out?

'123'x is a hex number.

'123' is a character string.

Re: about c2x bulid-in function

PostPosted: Sat May 21, 2011 10:29 am
by NicC
x means hex so it is passing a hex string in, character format, to C2X and is getting the hex representation back i.e. 2 bytes padded with leading zeros but in readable (character) format. Probably a bad use of C2X and possibly not one that was envisaged by Mike Cowlishaw - althoough it does not break the interpreter.