Rexx2Nrx.Rexx2RT.strfun (vs 4.00, January  2003)

The class strfun implements a couple of useful String routines which are available on some REXX systems as builtin routines, whilst not (yet) on other REXX implementations. Some of them are also available as NetRexx methods (like upper and lower). 

The class also contains a couple of my own routines used since years for varios utuility programs.

The following public static methods are available:

method set_delims(sv=Rexx) public static

resets the internal delimiter string ( a list of single characters acting as delimiters in the tokenizing routines, see also Scanner routines )

the default delimiters are:  delims = '"§$%&()[]{} +-*/.,;:!?<>=|#\\¬'''

method set_quote(quote_char) public static

sets the preferred quote character. (either single(') or double(") quote allowed). default is single quote. 

method set_letters(letters) public static

set the allowed letters of your alphabeth. default is A thru Z.

method cmpstr(sv1 = Rexx '',sv2 = Rexx '') static public returns int;

performs a case blind comparison  of the two strings sv1 and sv2

returns - 1 when sv1 < sv2, 0 when sv1 = sv2, and +1 when sv1 > sv2

method changestr(stringv = Rexx ,needle = Rexx, newv = Rexx) static public returns Rexx; 

changes all occurencies of needle in stringv to newv.

method countstr(stringv = Rexx '',needle = Rexx '') static public returns int; 

count all not-overlapping occurencies of needle in stringv

method lastchar(string = Rexx) static public returns Rexx; 

returns the last character of a given string. returns the null string '', when the given string is empty.

method char1(string = Rexx ,i_char = int 0) static public returns Rexx;

returns the single character of string at position i_char; returns the null string, if i_char is out of the bounds of the string (<1 or > length(s))

method extstr(stringv = Rexx ,i1 = int  [,i2=int] ) static public returns Rexx;

        extracts the substring of stringv from position i1 to position i2 (both inclusive),. If i2 is not given or zero,  up to the end of the string.stringv.

method upper(string = Rexx) static public returns Rexx; 

converts the given string to uppercase.

method lower(x18 = Rexx ) static public returns Rexx; 

converts the given string to lowercase.

method Capitals(x19 = Rexx ) static public returns Rexx;

converts the given string to capitals (first letter uppercase, rest lowercase)

method is_digit(cv1 = Rexx) static public returns boolean; 

tests if a given character is a digit.

method is_letter(cv1 = Rexx) static public returns boolean;

tests if a given character is a letter (A-Z). You may use set_letters(alphabeth) to define your local alphabeth (e.g. for including the special characters 'Ä',Ö','Ü' for instance). The test is case-blind. 

method is_upper(string = Rexx) static public returns boolean; 

tests if the whole given string is in uppercase letters.

 method is_lower(string = Rexx) static public returns boolean; 

tests if the whole given string is in lowercase letter.

method is_delim(charx = Rexx) static public returns boolean; 

tests if the given character charx is a delimiter (i.e. is one of the characters in  the current_delimiter string (initialized by set_delims). 

method is_member(x_item = Rexx, x_list = Rexx) static public returns boolean; 

test membership; test if x_item is in x_list (blank delimited WordList). Note that the comparison is case blind!

method member_no(x_item = Rexx ,x_list = Rexx) static public returns int; 

returns the item-number of x_item in x_list (like wordpos, but case-blind). For example, member_no('real','Int Real Float Number') is 2.

method is(x1=Rexx,x2=Rexx) public static returns boolean

case-blind comparison of equality of strings x1 and x2. You will have to use the functions  is(a,b), is_member(...) and member_no  for enumerated types.

method comma_list(WordList = Rexx) static public returns Rexx; 

convert a given blank-delimited Word-List to a comma-delimited list (actually a comma and a space ( ', ') are used as the delimiter for readability)

method is_quoted(s23 = Rexx) static public returns boolean;

tests if a given string is quoted, i.e. both the first and the last character are a quote (either single or double quote)

method quoted(s21 = Rexx) static public returns Rexx;

return QUOTED string; normally, the single quote is used. This may be overwritten by the method set_quote(quotechar). Imbedded single quotes are doubled.

method unquoted(s22 = Rexx) static public returns Rexx;

remove the leading and trailing quote character (may be single (') or double quote char (")). Imbedded double quotes are replaced by single quotes.

method is_mask(string=Rexx) static public returns boolean

tests if a given string contains  any mask characters (i.e. characters '*' or '?')

method masked(string = Rexx ,mask = Rexx) static public returns boolean; 

masked comparison routine, string is a simple string, mask contains the mask, e.g. '*.REXX' . this masked comparison is used to build 'FileLists' etc (see RexxFile.FileList), for instance. 

method Number(xx=Rexx) public static returns int

converts a given string to a Number (Integer). Used as a workaround to allow simulation of 'typing' in classic Rexx. An error occurs if xx does NOT contain a Number.