home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxhll.zip / STRING.REX < prev    next >
OS/2 REXX Batch file  |  1993-10-04  |  2KB  |  84 lines

  1.  
  2. /* #include <string.rex> */
  3.  
  4.  
  5. MapSymbol: procedure
  6.    /**
  7.    ***  This will translate the input string to the output string.
  8.    **/
  9.  
  10.    parse arg string, in, out
  11.  
  12.    outstring = ''
  13.    psn = pos(in, string)
  14.    do while(psn > 0)
  15.       if psn > 1 then
  16.          outstring = outstring || substr(string, 1, psn-1)
  17.       outstring = outstring || out
  18.       string = substr(string, psn+length(in))
  19.       psn = pos(in, string)
  20.    end
  21.    outstring = outstring || string
  22.    return outstring
  23.  
  24.  
  25. UpperCase: procedure
  26.    /**
  27.    ***  This will convert the string to uppercase
  28.    **/
  29.  
  30.    parse upper arg string
  31.    return string
  32.  
  33.  
  34. GetNoEcho: procedure
  35.    /**
  36.    ***  This will grab keystrokes and enter them back as '*' characters
  37.    **/
  38.  
  39.    Password = ''
  40.    Key = SysGetKey('NoEcho')
  41.    do while c2x(Key) <> '0D'
  42.       select
  43.          when c2x(Key) = '08' then
  44.             Password = left(Password, (length(password)-1))
  45.          otherwise
  46.             Password = Password || Key
  47.       end /* select */
  48.       Key = SysGetKey('NoEcho')
  49.    end
  50.    return Password
  51.  
  52.  
  53. LowerCase: procedure
  54.    /**
  55.    ***  This will return the string passed after converting it to lowercase
  56.    **/
  57.  
  58.    parse arg String
  59.    String = translate(String, "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  60.    return String
  61.  
  62.  
  63. FormatComma: procedure
  64.    /**
  65.    ***  This will take a string (that is presumably numeric, but not verified
  66.    ***  to be) and insert commas after groups of three digits
  67.    **/
  68.  
  69.    arg Raw .
  70.  
  71.    Formatted = ''
  72.    do while Raw \= 0
  73.       Formatted = right(Raw, 3)','Formatted
  74.       Raw = Raw % 1000
  75.    end
  76.    if Formatted = '' then
  77.       Formatted = 0
  78.    else
  79.       do
  80.       Formatted = Strip(Formatted,'Trailing',',')
  81.       Formatted = Strip(Formatted,'Leading',' ')
  82.       end
  83.    return Formatted
  84.