40. Functions and instructions in RXS

The definition of the two terms in the heading just above is:

The notation in this appendix is:

Syntax is described using typeset courier. Required elements are bold, optional are not bold. If an optional element is omitted, the comma in front of it is to be omitted too.

Elements written using UPPER CASE must be written exactly as stated here (you may use lower case), elements written using lower case must be replaced by a string or a variable containing a value.

Do notice: non-numeric strings in RXS must always be written in quotes.

If nothing is noted below, the concept is a function, and its heritage is REXX. Which means that further information can be found in a REXX manual.

Functions in RXS can be nested - for instance left(date(),2) will create a two digit string containing the current day in the month.

The list below is not exhaustive - any REXX functions and instructions may be used in RXS, except those mentioned in Section 2.

 

ABS(number)

ABS returns the absolute value of a number (stripping of the sign, returning a positive number or zero)

BITAND(string1,string2,pad)

BITAND returns a string containing the two input strings ANDed together bit for bit.

BITOR(string1,string2,pad)

BITOR returns a string containing the two input strings logically ORed together bit for bit.       

BITXOR (string1,string2,pad)

BITXOR returns a string containing the two input strings logically exclusive ORed together bit for bit.

B2X(binary_string)

Binary to hexadecimal - returns a string in character format, representing binary_string converted to hexadecimal.

CALL extprocedure parameter

The external REXX or CLIST program extprocedure is executed, optionally using the parameter parameter. (REXX instruction)

CENTER(string,length,pad)

CENTER returns a string of length length containing string centered inside it. pad characters may be added to reach the length.

CHANGE(oldval,newval,string,option)

CHANGE returns a string in which first, last or all occurences of another string, oldval is changed to the string newval. Option is F(irst) L(ast) or A(ll). A is default. (RXS function)

COMPARE(string1,string2,pad)

COMPARE compares string1 and string2. COMPARE returns 0 if the strings are identical. If the strings differ, the position of the first character not in match is returned.

COPIES(string,n)

COPIES returns n concatenated copies of string.

C2D(string,n)

Character to decimal - returns the decimal value of the binary representation of string. This function converts an IBM 'binary' field to a REXX numeric - for example, if string contains '05A8'x, the REXX numeric '1448' is created.

C2X(string)

Character to hexadecimal - converts a string to its hexadecimal representation. This function conterts an IBM 'packed decimal' to a REXX numeric - for example, if string contains '01448D'x, the REXX string '01448D' is created. If the last character is 'D' then multiply by -1. Remove last character.

DATATYPE(string,type)

DATATYPE returns - when only string is specified - NUM if string is a valid REXX number. Otherwise CHAR is returned. If type is specified, 1 is returned if string matches type, otherwise  0 is returned.

DATE(option)

DATE returns the actual date in the format dd mmm yyyy (if option is omitted) or in the format according to option. Option can be Base, Century, Days (number of day inside year), European (the format 13/03/92) , Julian, Month, Normal (the format 13 Mar 1992), Ordered, Standard (the format 19920313), Usa, Weekday (the day of the week in letters).  Only the first letter of option has to be written.

DELSTR(string,n,length)

DELSTR deletes the substring of string starting at the n'th character and being length long.

DELWORD(string,n,length)

DELWORD deletes the substring of string starting in the n'th word, being length blank-delimited words long.

DO

Lines in RXS contained inside lines DO and END are considered a block of lines (section 2a) (REXX instruction)

DROPQUEUE queue

DROPQUEUE removes the queue queue. (See Section 16). (RXS instruction).

DROP name

DROP restores variables to their original uninitialized state. If name is not enclosed in parentheses, it identifies a variable to drop. If a single name is enclosed in parentheses, then the value of name denotes a subsidiary list of variables to drop. (REXX instruction)

D2C(wholenumber,n)

Decimal to character - returns a character-string being the binary representation of the decimal number wholenumber.

D2X(wholenumber,n)

Decimal to hexadecimal - returns a character-string being the hexadecimal representation of the decimal number wholenumber.

END

Lines in RXS contained inside lines DO and END are considered a block of lines (section 2a) (REXX instruction)

EXIT number

The RXS program is halted immediate. If number is written the environment of the RXS program will receive number as return-code (normally in the variable RC). Any updates from the RXS program (DB2, MQ, and writing of files) will be rolled back. If the RXS program is executed directly from an edit-screen or as a command, an informative message is written. (RXS instruction)

FIND(string,phrase)

FIND searches string to find first appearance of phrase (where phrase is a string of blank-delimited words), returning the number of the word in string where the appearance starts. If phrase is not found, or phrase is empty, 0 is returned.

FORMAT(number,before,after,expp,expt)

FORMAT rounds and format number according to the stated: Before states the number of digits before the decimal separator, after states the number of digits after the decimal separator.

FROMISPF(dsname)

Converting a dsname from ISPF naming standard to RXS naming standard: If dsname begins with a quote, qutoes before and after is removed. If no quote is found, dsname is prefixed USERID()".". (RXS function).

GETQUEUE(queue_name, element_value)

GETQUEUE returns the value of unit.2 in the queue queue_name for the entry having unit.1 = element_value (See Section 15). (RXS function)

INDEX(haystack,needle,start)

INDEX returns the position of a string, needle, in another string haystack, starting the examination at start. If the string needle is not found, 0 is returned.

INSERT(new,target,n,length,pad)

INSERT inserts the string new, padded up to length length, into the string target starting at character n.

INTERPRET expression

INTERPRET executes expression: a string or a variable containing a valid statement in REXX syntax, or several valid statements, separated by ";". Example: interpret "if w = 14 then do;w = w - 1;end" Notice that RXS constructs is not allowed inside expression. (REXX instruction)

INTERFACE(in)

The function INTERFACE() using a queue-name in as argument, returns '1' if the indicated queue  in has been changed by the user during an edit session using an )interface in the current RXS program (RXS function)

ITERATE

Jump to the beginning of the current block of coding (DO END block) and execute from here. (REXX instruction)

JUSTIFY(string,length,pad)

JUSTIFY formats blank-delimited words in string by adding pad characters between the words so that the words fill out length.

LASTPOS(needle,haystack,start)

LASTPOS returns the last position of a string, needle, in another string haystack, starting the examination at start. If needle is empty or if needle is not found inside haystack, 0 is returned.

LEAVE

Jump past the end of the current block of coding (DO END block) and execute from here (REXX instruction).

LEFT(string,length,pad)

LEFT returns a string containing characters from the left of string up to length length.

LENGTH(string)

LENGTH returns the length of string.

MAKE_GLOBAL varname

The variable with the name varname is made globally accessible. See Section 33. (RXS instruction)

MAX(number1,number2,...)

MAX returns the largest number in the list

MIN(number1,number2,...)

MIN returns the smallest number in the list.

NOP

Dummy instruction with no effect. (REXX instruction)

OVERLAY(new,target,n,length,pad)

OVERLAY overlays tartget - starting at the n'th character - with the string new, padded and truncated to length length.

PARSE VAR string varname1 "," varname2 "," varname3

PARSE comes in a lot of flavors. The above form splits a string into three strings. The split occurs when the character ',' is found in string. For other uses of PARSE, see a REXX manual

POS(needle,haystack,start)

POS returns the first position of a string, needle, in another string haystack. The examination starts at position start.

QUEUE string

Concatenate string at buttom of the current queue. The current queue is normally used to hold sub-commands for tso commands using several sub-commands, like FTP (REXX instruction) (section 33j)

QUEUEVAR(queue_name, queue_element)

Queuevar returns 1 if queue_element is found in the queue queue_name, otherwise 0 is returned (See Section 14). (RXS function)

RANDOM(min,max,seed)

RANDOM returns a pseudo random non-negative number in the sequence from min to max inclusive. The difference between min and max may not exceed 100000. A specific seed for the generation may be given.

REVERSE(string)

REVERSE returns the bytes of string in reverse order.

RETURN

If the RXS program contains a series of prompts (Section 21) the first prompt will re-appear. Otherwise: The RXS program is halted immediate. Any updates from the RXS program (DB2, MQ, and writing of files) will be rolled back. (RXS instruction)

RIGHT(string,length,pad)

RIGHT returns a string of length length, including the rightmost character of string

SAY expression

expression is written on screen (REXX instruction)

SET_HALT string

string is presented as a message on the current screen presented to the user: The execution is temporarely halted after the current action-block – after which the current screen in a prompt is re-displayed with string as a message. (RXS instruction).

SET_MESSAGE string

string is presented as a message on the next screen presented to the user. (RXS instruction).

SIGN(number)

If number is negative, -1 is returned, if number is zero, 0 is returned, otherwise 1 is returned.

SPACE(string,n,pad)

SPACE formats blank-delimited words in string using n pad characters between each word. If n is zero, all blanks are removed.

STRIP(string,option,char)

STRIP removes Leading, Trailing or Both char from string, according to option being L(eading), T(railing) or B(oth). Default is B. Default for char is space.

SUBSTR(string,n,length,pad)

SUBSTR returns the substring af string starting at the n'th character. If length is omitted, the rest of the string is returned.

SUBWORD(string,n,length)

SUBWORD returns the substring of string starting at the n'th word, and being length long.

SYMBOL(name)

If name is not a valid REXX symbol, BAD is returned. If name is the name of a variable,  VAR is returned. Otherwise LIT is returned.

TIME(option)

TIME returns local time in the format '14:19:03' if option is not stated. Option is: Civil '2:19pm', Elapsed '0.000028' (number of seconds after reset), Hours '14' (number of hours since midnight), Long'14:09:03.050683', Minutes '859' (minutes since midnight), Normal '14:09:03', Reset (that is: resetting elapsed) and Seconds '51535' (Seconds since midnight). As option you may state the first letter, for instance 'c' for 'civil'.

TIMESTAMP()

TIMESTAMP returns the current timestamp in DB2-format:

yyyy-mm-dd-hh.mm.ss.mmmmmm

(RXS function)

TRANSLATE(string,tableo,tablei,pad)

TRANSLATE 'translates' the characters of string to other characters. If tableo and tablei is not stated, the string is translated to upper case.

TRUNC(number,n)

TRUNC returns the integer part of number and - if stated - n decimal places.

USERID()

Returns tso-userident

VALUE(name,newvalue)

VALUE returns the value that has been assigned to a variable name, and optionally assigns a new value newvalue to the variable name.

VERIFY(string,reference,option,start)

VERIFY verifies that string only contains characters from reference. If true, 0 is returned. If not true, the position of first character in string that is not in reference is returned. If option is 'nomatch', the function is reversed: it returns the position of the first character in string that is in reference. If start is stated, the examination starts at start.

WORD(string,n)

WORD returns the n'th blank-delimited word in string.

WORDINDEX(string,n)

WORDINDEX returns the position of the first character in the n'th blank-delimited word in string.

WORDLENGTH(string,n)

WORDLENGTH returns the length of the n'th blank delimited word in string.

WORDPOS(phrase,string,start)

WORDPOS searches string for the first occurrence of the sequence of blank-delimited words, phrase in string. The words in both strings may be separated by any number of blanks. If phrase is not found in string, 0 is returned.

WORDS(string)

WORDS returns the number of blank-delimited words in string.

X2B(hexstring)

Hexadecimal to binary - returns a string in character format representing hexstring binary.

X2C(hexstring)

Hexadecimal to character - converts a string of hexadecimal characters to character format.

X2D(hexstring,n)

Hexadecimal to decimal - converts a string of hexadeical characters to decimal