about c2x bulid-in function



IBM's Command List programming language & Restructured Extended Executor

about c2x bulid-in function

Postby Pumpkin » Thu May 19, 2011 1:57 pm

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!
-------------------
Pumpkin
Pumpkin
 
Posts: 55
Joined: Sat Mar 05, 2011 9:12 am
Has thanked: 0 time
Been thanked: 0 time

Re: about c2x bulid-in function

Postby enrico-sorichetti » Thu May 19, 2011 2:24 pm

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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: about c2x bulid-in function

Postby Pumpkin » Fri May 20, 2011 11:03 am

thanks for reply!
-------------------
Pumpkin
Pumpkin
 
Posts: 55
Joined: Sat Mar 05, 2011 9:12 am
Has thanked: 0 time
Been thanked: 0 time

Re: about c2x bulid-in function

Postby Pedro » Sat May 21, 2011 1:18 am

> what does the x mean,how this result come out?

'123'x is a hex number.

'123' is a character string.
Pedro Vera
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: about c2x bulid-in function

Postby NicC » Sat May 21, 2011 10:29 am

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post