Supporting methods *x2c* and *c2x* for Strings, not only one character in NetRexx class Rexx.nrx

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Supporting methods *x2c* and *c2x* for Strings, not only one character in NetRexx class Rexx.nrx

ThSITC
Hello all, there, especially Kermit & MFC:

When writing my first version of Rexx2Nrx, back early 2000, I did *notice* that the NetRexx class Rexx methods
*x2c* and *c2x* do only support the conversion of a single character, not for a String.

Oppositly, *x2c* and *c2x* are defined for a *character-sequence* (formelry called String, in Java, and other languages).

As far as I can remember, I did have some discussions about this with MFC, at those times, and he did say,
as far as I do remember, that it shall *not be possible* to define *x2c* and *c2x* for *character seuqneces* in
NetRexx, as it shall not be *sure* that a *character* chall always occufy 2 characters ...

For completeness, here, I'm including the *Functions* I did implement then in module *RexxHex*, at those times:

   
/*====================================================================*/
/* x2c: convert hexadecimal string to character string                */
/**********************************************************************/
method x2c(hexstring=Rexx) public static
   hexstring=hexstring.changestr(' ','') /* remove emedded blanks*/
   len=hexstring.length()
   c_string=''
   loop jj=1 to len by 4
      c_hex=hexstring.substr(jj,4)
      cx=c_hex.x2c
      c_string=c_string||cx
   end  
  
   return c_string

/***********************************************************************/
/* c2x: convert character string to hexadecimal string                 */
/***********************************************************************/  
method c2x(charstring=Rexx) public static
    len=charstring.length()
    x_string=''
    loop jj=1 to len by 1
       ch1=charstring.substr(jj,1) /* get ONE character only (UNICODE) */
       c_hex=ch1.c2x().right(4,'0') /* one Unicode character are 4 Hex chars */
       -- RexxMsg.debug('Character is:' ch1 'Hex:' c_hex)
       x_string=x_string||c_hex
    end
    return x_string  
--

==================================================================
May I now ask the maintainers of class Rexx.nrx to *add* the methods

method c2x() *and* x2c() again, when the current obhect is a Rexx String, in a similiar
manner as shown above, to reduce the *confusion* raised for people coming from classic
Rexx to NetRexx????

Happy Easter, all anyway,
and sorry for disrupting you, again !
========================================================================
Thomas.

Thomas Schneider, IT Consulting; http://www.thsitc.com; Vienna, Austria, Europe

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Thomas Schneider, Vienna, Austria (Europe) :-)

www.thsitc.com
www.db-123.com