String manipulation functions: Ord, Ordascii, Ordebcdic

Top  Previous  Next

When called with a string the ord command returns the ASCII code number of a character in a position in a string and is referenced as

 

Ord(string,place);

or

namedscalar=Ord(string,place);

 

where the strings are just the same as in Card above.  The place entry is optional defaulting to one if omitted but otherwise identifying the character position within the text string (1 for the first, 2 for the second etc.) to be examined.  The alternative command ordascii may be used in place of ord to return ASCII codes while ordebcdic may be used to return EBCDIC codes.

Example:

(string.gms)

$oneolcom

set id namedset /i1 i have explanatory text,ifour,a/;

scalar ii;

 

ii=Card(id.ts);  !! length of symbol test string

display 'length of text string for symbol', ii;

 

loop(id,

    ii=Card(id.tl)  !! length of label id   (id must be driving)

    display  'length of set element string', ii;

 

   ii=Card(id.te)   !! length of label text (id must be driving)

   display 'length of set explanatory text string', ii;

);

 

   ii= Card('xxx')  !!  length of 'xxx'

   display 'length of string', ii;

 

parameter rdd abcdefghijklmnopqrstuvwxyz;

scalar j;

for (j=1 to 27 by 1 ,

   io=Ord(rdd.ts, j);        !! char number

   ia=Ordascii(rdd.ts, j);   !! char number      

   ie=Ordebcdic(rdd.ts, j);  !! char number 

display 'ords of text string for symbol',j, io,ia,ie;);