Arithmatic

+

-

*

/

% Divide and return integer part

// Divide and return remainder (may be neg result)

** Raise to power

- (prefix) Negate value

+ Treat as 0+variable

Comparison

== Exactly equal

= About equal (pad or numeric equivalent)

\=[=] NOT [exactly] equal

ª=[=] same (not symbol)

< less than

> greater than

>|< strictly greater|less than

Logical (boolean)

& and

| or

& exclusive or

\ (prefix) NOT (also not symbol)

|| concatenation

Precedence

prefix

power

multiply/divide

add/subtract

concatenation

comparison

and

or/exclusive or

Labels symbol followed by : ie labela:

Constants 123 'abC' "abC" 'a0a'x

Keyword instructions

ADDRESS [ISPEXEC|TSO|BATCH] no parm returns current value

ARG parse pased arguments - same as PARSE UPPER ARG

CALL invoke something (PC- var 'result' contains return)

CALL name expression[ expression]...[ expression]

var=name(expr[ expr]...[ expr]) var gets return

*** PC - no commas between expressions ***

CALL OFF|ON ERROR|FAILURE|HALT [NAME trapname]

DO looping

DO [repetitor] [conditional] ; END;

repetitor name=expr [TO] [BY] [FOR]

FOREVER

expression

conditional WHILE|UNTIL

DROP unassign variable

EXIT terminate (leave) procedure EXIT expression

IF conditional IF expr THEN stmt ELSE stmt (1=true,0=false)

INTERPRET evaluate expression then execute it

ITERATE skip to end of [named] DO loop ITERATE [var_name]

LEAVE exit DO loop immediately LEAVE [var_name]

NOP no operation

NUMERIC alter calcs DIGITS num set precision dflt 9

FORM SCIENTIFIC|ENGINEERING|etc

FUZZ num set digits ignored in comparison

OPTIONS DBCS setup

PARSE parsing strings

PARSE [upper] arg|external|numeric|pull|source|var var_name|

version|value [expression] with|

arg arguments

external terminal

numeric numeric settings

pull stack then terminal

source environment description

var contents of variable

value variable evaluated then parsed

version language version info

PROCEDURE identify internal subroutine name: PROCEDURE [EXPOSE var_name]

PULL same as PARSE UPPER PULL

PUSH put on stack (lifo)

QUEUE put on stack (fifo)

RETURN return control RETURN expression

SAY type on terminal

SELECT execute one of following instructions

SELECT WHEN expr THEN stmt

WHEN expr THEN stmt

OTHERWISE stmt

END

SIGNAL transfer control (addl info for errors below)

SIGNAL label_name

VALUE expression

TRACE tracing options [?|!] [ALL|COMMANDS|ERROR|FAILURE| ,

INTERMEDIATES|LABELS|NORMAL|OFF| ,

RESULTS|SCAN]

TRACE ?I TRACE VALUE expression

? interactive tracing

! do not execute host commands - set rc to 0 for each

TRACE number (? active only) +num = skip num pauses

-num = off trace num clauses

UPPER convert to upper case (not assignment stmt) UPPER var_name

FUNCTIONS

ABBREV(information,info[,length]) 1|0 1 if info is first length chars of

ABS(number) absolute value

ADDRESS() get envorinment name TSO|MVS|ISPEXEC|CMD (pc)| (others?)

ARG([n] [,Exists|Omitted]) get # args or nth arg or 1|0 if nth E|O

BITAND(string1 [,|,string2 [,pad]]) logical AND

BITOR logical OR (same as and)

BITXOR logical XOR

CENTER(string,length[,pad])

COMPARE(string1,string2[,pad]) 0=equal, n=non-matching character

CONDITION(...) info about trapped conditions

COPIES(string,n) make n copies of string

C2D(string[,n]) treat string as binary integer, ret n digits C2D('81'x)=129

C2X(string) return hex value for each byte C2X('123')='F1F2F3'

DATATYPE(string[,type]) CHAR|NUM

type codes return 1|0 for match|not match type

Alphanumeric Binary C Dbcs Lowercase Mixed_case Number

Symbol Uppercase Whole_number heXadecimal

DATE(option) Base days from 1/1/1 DATE('B')//7=0..6 (Mon..Sun)

Century days since Jan 1 of last century

Days days since start this year

European dd/mm/yy

Julian yyddd

Month January..December

Normal dd mon yy DEFAULT

Ordered yy/mm/dd

Standard yyyymmdd

Usa mm/dd/yy

Weekday Monday..Sunday

DELSTR(string,n[,length]) delete length chars starting with n

DELWORD(string,n[,length]) delete length words starting with word n

DIGITS() get current setting of NUMERIC DIGITS

D2C(integer) convert integer to string D2C(129) = 'a'

D2X(integer[,n]) convert integer to hex output length n

ERRORTEXT(n) get text for REXX error code

FORM() get NUMERIC FORM setting

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

FUZZ() get current NUMERIC FUZZ setting

INSERT(new,target[,n,length,pad]) insert new into target after n

LASTPOS(needle,haystack[,start])

LEFT(string,length[,pad])

LENGTH(string)

MAX(n,n,...n) get largest n

MIN get smallest n

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

POS(needle,haystack[,start])

QUEUED() get number lines in queue

RANDOM() random numbers (000..999) other parms too

REVERSE(string) reverse chars in string

RIGHT(string,length[,pad])

SIGN(number) +1 -1 0

SOURCELINE([n]) # lines in procedure or Nth line

SPACE(string[,[n][,pad]]) put n pad chars between words of string

STRIP(string[,Both|Leading|Trailing[,char]])

strip B (default) L T char from string. Char dflt = space

SUBSTR(string,n[,[length][,pad]]) start at n specified length with pad

SUBWORD(string,n[,length]) get length words starting at n (dflt to end str)

SYMBOL(name) result is LIT|VAR|BAD

TIME(option) Civil|Elapsed|Hours|Long|Min|Normal|Reset|Seconds

elapsed & reset are for elapsed-time clock

TRACE() get trace option in effect

TRANSLATE(string,tableo,tablei,pad)

TRUNC(number,n) set n decimal places

VALUE(name)

VERIFY(string,ref[,option[,start]]) 1 if all string chars in ref

WORD(string,n) get nth word in string

WORDINDEX(string,n) get char pos of nth word in string

WORDLENGTH(string,n) get length of nth word in string

WORDPOS(phrase,string[,start]) get word# of phrase in string at/after start

WORDS(string) count of words in string

XRANGE(start,end) XRANGE('a','f') = 'abcdef' = '818283848586'x

X2C(hexstring) X2C('F7f7 A2') = '72s'

X2D(hexstring[,n]) get decimal conversion X2D('81')=129 X2D('FF81')=65409

TSO functions (use as var_name = FUNCTION)

GETMSG (msgstem [,|,msgtype [,|,cart [,|,mask [,|,time]]]])

get messages issued during console sessions

LISTDSI(dsn [VOL(volid)|PREALLOC] [DIRECTORY] [RECALL|NORECALL])

(filename FILE [DIRECTORY] [RECALL|NORECALL]

output variables are:

SYSDSNAME

SYSVOLUME

SYSUNIT

SYSDSORG PS DA IS PO VS ??? (+U=unmoveable)

SYSRECFM

SYSLRECL

SYSBLKSIZE

SYSKEYLEN

SYSALLOC (allocated space)

SYSUSED

SYSPRIMARY

SYSSECONDS

SYSUNITS CYLINDER TRACK BLOCK ????????

SYSEXTENTS

SYSCREATE

SYSREFDATE

SYSEXDATE expiration date

SYSRACFA NONE GENERIC DISCRETE

SYSUPDATED YES NO

SYSTRKSCYL

SYSBLKSTRK

SYSUDIRBLK directory blocks used

SYSMEMBERS number of members

SYSREASON return code (0 = ok)

SYSMSGLVL1 first level error message

SYSMSGLVL2 second level error message

MSG(['on'|'off']) status of TSO MSG in profile (on|off to set)

OUTTRAP(off|varname [,max[,CONCAT|NOCONCAT]])

varname ends with a period

max is max lines to trap (dflt="*"=999999999)

concat to add to existing stem variable (NO dflt)

varname.0 number lines containing data

varname.TRAPPED total # lines of command output

PROMPT(["ON"|"OFF"]) return/set prompt status

SETLANG(language)

STORAGE(address [,|,length [,data]])

address char hex address string

length decimal # bytes to retrieve (dflt 1)

data replacement data (character string)

SYSDSN(dsname) OK

MEMBER NOT FOUND

MEMBER SPECIFIED, BUT DATASET IS NOT PARTITIONED

DATASET NOT FOUND

ERROR PROCESSING REQUESTED DATASET

PROTECTED DATASET

VOLUME NOT ON SYSTEM

MISSING DATASET NAME

UNAVAILABLE DATASET

SYSVAR(arg_name) SYSCPU # cpu secs used in session sss.hh

SYSENV FORE|BACK

SYSHSM

SYSICMD name of command user invoked

SYSISPF ACTIVE|NOT ACTIVE

SYSLRACF

SYSLTERM number lines available on terminal

SYSNEST YES|NO second level clist

SYSPCMD name of last processed cmd procssr

SYSPREF current prefix

SYSPROC logon procedure name

SYSRACF AVAILABLE|NOT AVAILABLE|NOT INSTALLED

SYSSCMD name last subcmd processor

SYSSRV SRM service units used

SYSTSOE

SYSUID current userid

SYSWTERM number chars/line

and others

TSO commands

DELSTACK delete most recently created stack (& all vars in it)

DROPBUF delete most recently created data stack buffer

EXECIO *|lines DISKW ddname [(STEM varname [OPEN] [FINIS])]

DISKR ddname [linenum][(FIFO ] [OPEN] [FINIS] [SKIP])]

LIFO

STEM varname

DISKRU same as DISKR

* all lines (from stack stops at null line)

lines # lines (0=don't read any lines )

ddname ddname already allocated to data set

DISKx W=write, R=read, RU read & update last read with EXECIO DISKW

linenum first line to process (open & skip to rec 100 w/1 as 1st rec)

FIFO/LIFO how to place on stack

STEM varname name of stem variable to receive lines

OPEN open file (must be closed - ignored if already open)

FINIS close file after reading last rec or writing rec(s)

SKIP read lines but don't place on stack or in vars

EXECUTIL change characteristics of how REXX works

EXECDD(CLOSE|NOCLOSE) close SYSEXEC lib >locate <exec of called REXX

TS trace start (as TSO command starts tracing of next REXX)

TE trace end - ends all tracing - use within REXX

HT halt typing - suppress terminal output

RT resume typing

HI halt interpretation

RENAME NAME(func_name) [SYSNAME(sys_name)] [DD(sys_dd)]

SEARCHDD(NO|YES) search SYSEXEC for implicit invoked REXX

also affected by ALTLIB (TSO/E) facility

HE halt execution (from attn interrupt) (will halt REXX & extern funcs)

HI halt interpretation

HT halt typing

TS/TE trace start/end (can use after interrupt of REXX)

MAKEBUF create a new buffer on the data stack

rc set to total buffers created on this stack

NEWSTACK make a new data stack

QBUF get number of buffers created on this stack (rc has result)

QELEM get number of elements (rc) in current buffer (use MAKEBUF first)

QSTACK get number of stacks (rc) created (1 = original only)

RT resume typing

SUBCOM envname query if envname is current environment (rc=0|1 0=yes)

TSO CONSOLE CPICOMM LU62 MVS LINK ATTACH LINKPGM ATTACHPGM LINKMVS ATTACHMVS

TE trace end

TS trace start

PARSING

PARSE [UPPER] input output [sep] [,] output [sep] ......

input --|VALUE 'literal' parse the value specified

|VAR varname parse the contents of varname

|ARG parse the arguments

|PULL get input from stack/terminal

output name of variable to receive data use a . for null variable

sep separator (in input) use char string, number, variable

char string is not made part of output

num is start position of next variable

signed numbers indicate displacement from current pos

var put separator in var and enclose var in () in parse stmt

, after 1st output indicates rest of input is to be placed in

preceeding variable. Parser then goes on to the next

input argument. Used only to parse arguments to a function

because that is only time multiple strings available.

TRAPS & ERRORS (signal)

|CALL | |ON | condition [NAME trapname]

|SIGNAL| |OFF|

conditions ERROR non-zero return codes

FAILURE failure (TSO/E = negative rc)

HALT external attempt to stop (TSO/E HI)

NOVALUE read uninitialized variable

SYNTAX syntax error

trapname label of routine to handle error. error condition name if

not specified

notes: Trap is set off when invoked. Turn back on in routine if

necessary.

Special handling of errors during interpret (see manual)

DEBUGGING

Interactive trace by a ? in front of trace option

interact trace stops after each instr

null entry execute next stmt

= repeat last stmt executed (some not repeatable)

all else string of REXX commands to be immed executed

PC functions (return values to procedure)

linein(f_spec[,[1][,1|0]) read 1|0 lines, reposition start if 2nd parm = 1

lineout(f_spec,chars[,1]) write a line, reposition start if 3d parm = 1

lineout(f_spec) close the file

chars(f_spec) number of chars left to ?EOF

x = value("var_name",,"OS2ENVIRONMENT") fetch environment variable

char{in|out}(name[,start,length]) read length (dflt 1) chars

** reads all control chars including* start - disp from beg of file

** 0d0a at end of line * name - dflt to STDIN

rc - variable set when returning from OS/2 command

Authored by Philip Sherman