C2x (character to hexadecimal), Datatype, C2x (character to hexadecimal) datatype – IBM SC34-5764-01 User Manual

Page 202

Advertising
background image

If string is null, returns 0.

Here are some examples:

C2D('09'X)

->

9

C2D('81'X)

->

129

C2D('FF81'X)

->

65409

C2D('')

->

0

C2D('a')

->

129

/*

EBCDIC

*/

If you specify n, the string is taken as a signed number expressed in n characters. The number is positive
if the leftmost bit is off, and negative, in two's complement notation, if the leftmost bit is on. In both cases,
it is converted to a whole number, which may, therefore, be negative. The string is padded on the left with
'00'x characters (note, not “sign-extended”), or truncated on the left to n characters. This padding or
truncation is as though RIGHT(string,n,'00'x) had been processed. If n is 0, C2D always returns 0.

Here are some examples:

C2D('81'X,1)

->

-127

C2D('81'X,2)

->

129

C2D('FF81'X,2)

->

-127

C2D('FF81'X,1)

->

-127

C2D('FF7F'X,1)

->

127

C2D('F081'X,2)

->

-3967

C2D('F081'X,1)

->

-127

C2D('0031'X,0)

->

0

Implementation maximum: The input string cannot have more than 250 characters that are significant in
forming the final result. Leading sign characters ('00'x and 'FF'x) do not count toward this total.

C2X (Character to Hexadecimal)

C2X(string)

returns a string, in character format, that represents string converted to hexadecimal. The returned string
contains twice as many bytes as the input string. For example, on an EBCDIC system, C2X(1) returns F1
because the EBCDIC representation of the character 1 is 'F1'X.

The string returned uses uppercase alphabetics for the values A–F and does not include blanks. The string
can be of any length. If string is null, returns a null string.

Here are some examples:

C2X('72s')

->

'F7F2A2' /* 'C6F7C6F2C1F2'X in EBCDIC */

C2X('0123'X)

->

'0123'

/* 'F0F1F2F3'X

in EBCDIC */

DATATYPE

DATATYPE(string

,type

)

returns NUM if you specify only string and if string is a valid REXX number that can be added to 0 without
error; returns CHAR if string is not a valid number.

If you specify type, returns 1 if string matches the type; otherwise returns 0. If string is null, the function
returns 0 (except when type is X, which returns 1 for a null string). The following are valid types. (Only the
capitalized and highlighted letter is needed; all characters following it are ignored. Note that for the
hexadecimal

option, you must start your string specifying the name of the option with x rather than h.)

Alphanumeric

returns 1 if string contains only characters from the ranges a–z, A–Z, and 0–9.

Functions

180

CICS TS for VSE/ESA: REXX Guide

Advertising