Perform REXX Functions in Source Editor Macros

REXX functions can perform many useful operations in Source Editor macros. A functions can appear in an arithmetic or comparison expression, and the results returned by a function can also be assigned to a variable.

Only a few of the most useful REXX functions are briefly described here. For a complete list of REXX functions, refer to any REXX language and programming reference.

REXX Function Name Description
abs(num) 
Returns the absolute value of num.
center(str, num)
Returns a string of length num characters, with the string str centered in the returned string. If the length of str is greater than num, characters are truncated off each end of str, starting from the right end.
copies(str, num)
Returns num copies of the string str.
date(opts)
If no option is specified, returns the current date in dd/mon/yyyy format. Some options are:
days 
Return the number of days so far this year, in form ddd with no leading zeros.
european 
Return the date in European dd/mm/yy format.
month 
Returns only the full English spelling of the current month of the year.
ordered 
Returns the date in yy/mm/dd format.
sorted
Returns the date in yyyymmdd format.
usa 
Returns the date in mm/dd/yy format.
weekday 
Returns only the full English spelling of the current day of the week.
datatype(var) 
Evaluates the type of data in var. If numeric, function returns NUM. If a character or string, function returns CHAR.
delstr(str, num_1, num_2) 
Deletes characters from the string str, starting at character num_1 in the string, and continuing for num_2 characters. If num_2 is not specified, characters are deleted to the end of the string.

The function returns the remaining characters in the string. If num _1 is larger than the length of str, the complete string is returned unchanged.

delword(str, num_1, num_2 ) 
Deletes words from the string str, starting at word num _1 in the string, and continuing for num_2 words. If num_2 is not specified, words are deleted to the end of the string.

The function returns the remaining words in the string. If num_1 is greater than the number of words in str, the complete string is returned unchanged.

insert(new_str, str, num_1, num_2, char) 
Inserts the string new_ str into another string str, starting after character position num_1. If a value is specified for num_2, the string being inserted is padded to that number of characters. The default padding character is a blank unless otherwise specified by char.
length(str) 
Returns the number of characters in str.
substr(str, num_1, num_2) 
Returns a substring from the string str, starting at character num_1, for a length of num_2 characters. If num_2 is not specified, the rest of the string is returned.
subword(str, num_1, num_2 ) 
Returns a substring from the string str, starting at word num_1, for a length of num_2 words. If num _2 is not specified, the rest of the string is returned.
time(opts)
If no option is specified, returns the current time in 24-hour clock hh/mm/ss format. Some options are:
civil 
Returns the time in 12-hour clock format, showing hours and minutes followed by am or pm, for example, 12:10am.
hours 
Returns the number of hours since midnight, with no leading zeros.
minutes 
Returns the number of minutes since midnight, with no leading zeros.
seconds 
Returns the number of seconds since midnight, with no leading zeros.
trunc(num_1, num_2) 
Returns the value of num_1 truncated (or expanded) to num_2 decimal places. If num_2 is not specified, 0 is assumed for its value.
word(str, num) 
Returns the num'th word from string str. If num is greater than the number of words in str, the null string is returned.
wordindex(str, num) 
Returns the character position of the first letter of the num'th word in string str, or 0 if num is greater than the number of words in str.
wordlength(str, num) 
Returns the length of the num'th word in string str, or 0 if num is greater than the number of words in str.
words(str, num) 
Returns the number of words in the string str.