Rexx is supported in a variety of environments. It is the primary scripting language in some operating systems including OS/2, MVS, VM, AmigaOS and is used for macros in some software including SPF/PC, KEDIT, THE and ZOC. With an engine installed, Rexx can be used for scripting and macros in programs that use a Windows Scripting HostActiveX scripting engine (such as VBScript or JScript). Rexx is supplied with VM/SP Release 3 on up, TSO/E Version 2 on up, OS/2 (1.3 and later, where it is officially named Procedures Language/2), AmigaOS Version 2 on up, PC DOS (7.0 or 2000), ArcaOS,[9] and Windows NT 4.0 (Resource Kit: Regina). In the late 1980s, Rexx became the common scripting language for IBM Systems Application Architecture, where it was renamed "SAA Procedure Language REXX".
A script is associated with a Rexx interpreter at runtime in various ways based on context. In mainframe computing, a Rexx script or command is sometimes referred to as an EXEC since that is the name of the file type used for similar CMSEXEC,[10] and EXEC 2[11] scripts and for Rexx scripts on VM/SP R3 through z/VM. The first line of a script specifies the use of a Rexx interpreter in a comment either by identifying the code as Rexx language or by file path via EXTPROC. On MVS, Rexx scripts may[a] be recognized by the low level qualifier "EXEC" or if the first line fetched from SYSPROC is a comment containing "REXX" then it is treated as Rexx (rather than CLIST), and a script fetched from SYSEXEC must be Rexx. On OS/2, Rexx scripts share the filename extension ".cmd" with other scripting languages, and the first line of the script specifies the interpreter to use. On Linux, Rexx scripts generally begin with a shebang. Rexx macros for Rexx-aware applications use extensions determined by the application.
Name
Originally, the language was called REX, short for Reformed Executor, but an extra "X" was added to avoid confusion with other products. The name was originally all uppercase because that was the only way to represent it in mainframe code at the time. Both editions of Mike Cowlishaw's first book on the language use all-caps, REXX, although the cover graphic uses mixed case. His book on NetRexx uses mixed case but all caps in the cover graphic with large and small caps, NETREXX. An expansion that matches the abbreviation, REstructured eXtended eXecutor, was used for the system product in 1984.[12] The name Rexx (mixed case) is used in this article, and is commonly used elsewhere.
Attributes
Objective and subjective attributes of Rexx include:
Simple syntax
Ability to route commands to multiple environments
Ability to support functions, procedures and commands associated with a specific invoking environment.
Built-in stack with the ability to interoperate with the host stack if there is one
Small instruction set
Free-form syntax; indentation is optional but can help readability
Straightforward access to system commands and facilities
Simple error-handling, and built-in tracing and debugger
Few artificial limitations
Simplified I/O facilities
Unconventional operators
Only partly supports Unix style command line parameters, except specific implementations
Provides no basic terminal control as part of the language, except specific implementations
Provides no generic way to include functions and subroutines from external libraries, except specific implementations
Some claim that Rexx is a relatively simple language. With only 23 instructions (such as call, parse, and select), it has a relatively small instruction set. Rexx has limited punctuation and formatting requirements. Rexx has only one data type, the character string. Some claim that such simplicities make Rexx relatively easy to debug.
Some claim that Rexx code looks similar to PL/I code, but has fewer notations. With fewer notations, it tends to be is harder to parse via a translator, but is easier to write. Simplifying coding was intentional as noted by the Rexx design goal of the principle of least astonishment.[12]
History
pre–1990
On his own time, Mike Cowlishaw developed the language and an interpreter for it in assembly language between 20 March 1979 and mid-1982 with the intent to replace the languages EXEC and EXEC 2.[6] Mike also intended Rexx to be a simplified and easier to learn version of PL/I, but some claim that Rexx has problematic differences from PL/I.
Rexx was first described in public at the SHARE 56 conference in Houston, Texas, in 1981,[13] where customer reaction, championed by Ted Johnston of SLAC, led to it being shipped as an IBM product in 1982.
ARexx, a Rexx interpreter for Amiga, was included with AmigaOS 2 onwards and was popular for scripting and application control. Many Amiga applications have an "ARexx port" which allows control of the application via a Rexx script. Notably, a Rexx script can switch between Rexx ports to control multiple applications.
1990 to present
In 1990, Cathie Dager of SLAC organized the first independent Rexx symposium, which led to the forming of the Rexx Language Association. Symposia are held annually.
In 1992, the two most widely used open-source ports appeared: Ian Collier's REXX/imc for Unix and Anders Christensen's Regina[5] (later adopted by Mark Hessling) for Windows and Unix. BRexx was developed by Vasilis N Vlachoudis, a nuclear scientist at CERN. It runs on a range of operating systems, including Unix, Linux, BSD, macOS and Windows. Its small size means it can run on an Android mobile phone. BRexx/370 is a version that runs on IBM mainframes.[15]: 359–383 [17]
OS/2 has a visual development system from Watcom VX-REXX. Another dialect was VisPro REXX from Hockware.
Portable Rexx by Kilowatt and Personal Rexx by Quercus are two Rexx interpreters designed for DOS and can be run under Windows as well using a command prompt. Since the mid-1990s, two newer variants of Rexx have appeared:
NetRexx: compiles to Javabyte-code via Java source code; this has no reserved keywords at all, and uses the Java object model, and is therefore not generally upwards-compatible with 'classic' Rexx.
In 1996 the American National Standards Institute (ANSI) published a standard for Rexx: ANSI X3.274–1996 "Information Technology – Programming Language REXX".[c] More than two dozen books on Rexx have been published since 1985.
Rexx marked its 25th anniversary on 20 March 2004, which was celebrated at the Rexx Language Association's 15th International REXX Symposium in Böblingen, Germany, in May 2004.
On October 12, 2004, IBM announced their plan to release their Object REXX implementation's sources under the Common Public License. Recent releases of Object REXX contain an ActiveX Windows Scripting Host (WSH) scripting engine implementing this version of the Rexx language.
On February 22, 2005, the first public release of Open Object Rexx (ooRexx) was announced. This product contains a WSH scripting engine which allows for programming of the Windows operating system and applications with Rexx in the same fashion in which Visual Basic and JScript are implemented by the default WSH installation and Perl, Tcl, Python third-party scripting engines.
In January 2018 the TIOBE index listed Rexx at position 30.[19] Since 2018 it has been either outside the top 50, or, more frequently, outside the top 100.
In 2019, the 30th Rexx Language Association Symposium marked the 40th anniversary of Rexx. The symposium was held in Hursley, England, where Rexx was first designed and implemented.[20]
Toolkits
RexxUtil – a package of file and directory functions, windowed I/O, and functions to access system services such as WAIT and POST – is available for most Rexx environments.[21][22][23]
Rexx/Tk – a toolkit for graphics to be used in Rexx programmes in the same fashion as Tcl/Tk – is widely available.
RxSock for network communication as well as other add-ons to and implementations of Regina Rexx have been developed, and a Rexx interpreter for the Windows command line is supplied in most resource kits for various versions of Windows and works in DOS as well.
Host environment
A Rexx host environment is a named interface for sending commands to an, e.g., application, operating system, subsystem. The Rexx interpreter initially has a list of known environments; the first in the list is known as the default environment. A Rexx script use the ADDRESS statement to change the default environment and may also use it to send a single command to a specific environment without changing the default environment.
Assignments – Single clause of the form symbol=expression, assigns a value to a variable; e.g. count=count+1, would add 1 to value in variable "count".
Keyword instructions – The keyword is the first word of the instruction; e.g. say "Message", would print the word 'Message'.
Commands – an expression that the interpreter evaluates and passes as a command to the default environment; e.g. "sleep 10" would cause a Unix-like host environment to produce a ten seconds delay.
Address instruction
The address instruction has three roles:
An address instruction with no operand interchanges the first two host environments; normally this reinstate the previous default environment.
An address instruction with only an environment moves it to the beginning of the list, making it the default environment.
An address instruction with an environment and an expression passes the value of the expression as a command to the specified environment.
The ANSI standard added options for redirecting the input and output of commands.
Do groups
The language provides do groups for two purposes:
To treat a group of instructions within an if or select statement as a unit for purposes of flow control.
For loop control, similar to many other languages. A single do group may optionally contain repetitor phrases, conditional phrases, or both, with termination whenever any of them is satisfied.
A do group begins with do and ends with end. A single group may serve both purposes. In the related ooRexx and NetRexx, there is both a do and a loop keyword, with almost identical semantics; they differ in that a simple do is equivalent to do 1 while a simple loop is equivalent to loop forever.
An iteration of a do group may be terminated with an iterate statement and the entire group may be terminated with a leave statement.
Simple do
Although it is valid anywhere, a simple do is specifically useful inside conditional statements:
iffoo=bar
thendoi=1;j=3endelsedoi=2;j=4end
Conditional loop
The language supports testing a condition either before (do while) or after (do until) executing a group of code via syntax:
do while [condition]
[instructions]
end
do until [condition]
[instructions]
end
Simple repetitive loop
The language permits counted loops, where an expression is computed at the start of the loop and the instructions within the loop are executed that many times:
doexpression
[instructions]
end
Controlled Repetitive Loops
A loop can increment a variable and stop when a limit is reached.
doindex=start [tolimit] [byincrement] [forcount]
[instructions]
end
The increment value is 1 if the by clause is omitted. The loop continues forever if the limit to clause is omitted, unless terminated earlier by another clause or by a leave statement.
Unconditional loop
The language supports an unconditional loop via forever that continues until the loop is terminated or the program is terminated.
do forever
[instructions]
end
Combined loop
Repetitive elements and conditional phrases can be combined in the same loop;[24]: 50 e.g.:
doi=1whilei<=3;sayi;end
doindex=start [tolimit] [by increment] [forcount] [whilecondition]
[instructions]
end
doexpression [untilcondition]
[instructions]
end
Conditional
The language provides for conditional execution via if, then and else for a group delimited by do and end.
if [condition] thendo
[instructions]
endelsedo
[instructions]
end
For a single instruction, do and end can be omitted.
if [condition] then
[instruction]
else
[instruction]
Multiple condition branching
The language provides multiple condition branching via select which derives from the SELECT; form of the PL/I SELECT statement
.[d] Like similar constructs in other dynamic languages, Rexx's when clauses specify full conditions – not equality tests of a single value for the statement as some languages do. In that, they are more like cascading if-then-else code than like the C or Java switch statement.
selectwhen [condition] then
[instruction or nop]
when [condition] thendo
[instructions or nop]
endotherwise
[instructions or nop]
end
The nop instruction is required if no action is associated with a when condition.
The otherwise clause is optional. If omitted and no when conditions are met, then the syntax condition is raised.
Variable
Typing system
Variables are typeless and initially are evaluated as their names in upper case. Thus a variable's type can vary with its use in the program:
If no novalue condition handler is configured, then an undefined variable evaluates to its name, in upper case. The built-in function SYMBOL returns "VAR" for a defined variable and does not trigger novalue even if not defined. The VALUE function gets the value of a variable without triggering a novalue condition, but its main purpose is to read and set environment variables, similar to POSIXgetenv and putenv.
Compound variable
The language provides the compound variable construct which supports adding fields (called tails) to a variable (called a stem in this context) to support data structures such as lists, arrays, n-dimensional arrays, sparse or dense arrays, balanced or unbalanced trees and records.
The language does not provide special support for numeric array indexing like many other languages do. Instead, a compound variable with numeric tails produce a similar effect.[25]
The following code defines variables stem.1 = 9, stem.2 = 8, stem.3 = 7...
doi=1to10stem.i=10-i
end
Unlike a typical array, a tail (index) need not identify (be named) an integer value. For example, the following code is valid:
i='Monday'
stem.i=2
A default value can be assigned to a stem via . but no tail.
In this case stem.3, for example, evaluates to the default value, 'Unknown'.
The whole stem (including any default value) can be erased with the drop statement.
dropstem.
By convention (not part of the language) the compound stem.0 is often used to keep track of how many items are in a stem, for example a procedure to add a word to a list might be coded like this:
Multiple numerical tail elements can be used to provide the effect of a multi-dimensional array.
Features similar to the compound variable are found in other languages including associative arrays in AWK, hashes in Perl and hash tables in Java, dynamic objects in JavaScript. Most of these languages provide a mechanism to iterate over the keys (tails) of such a construct, but this is lacking in classic Rexx. Instead, it is necessary to store additional information. For example, the following procedure might be used to count each occurrence of a word.
add_word:procedureexposecount.word_list
parseargw.count.w=count.w+1/* assume count. has been set to 0 */ifcount.w=1thenword_list=word_listw
return
and then later:
doi=1towords(word_list)w=word(word_list,i)saywcount.w
end
More recent Rexx variants, including Object REXX and ooRexx, provide a construct to iterate over the tails of a stem.
doioverstem.sayi'-->'stem.i
end
Parse
The parse instruction provides string-handling via syntax:
parse [upper] origin [template]
If upper is included then the input is converted to upper case before parsing.
origin describes the input as one of the following:
arg – arguments, at top level tail of command line
linein – standard input, e.g. keyboard
pull – Rexx data queue or standard input
source – info on how program was executed
valueexpressionwith – with indicates the end of the expression
var – a variable
version – version/release number
template can be a combination of variables, literal delimiters, and column number delimiters.
Examples
Using a list of variables as template:
myVar="John Smith"parsevarmyVarfirstNamelastName
say"First name is:"firstName
say"Last name is:"lastName
displays:
First name is: JohnLast name is: Smith
Using column number delimiters:
myVar="(202) 123-1234"parsevarMyVar2AreaCode57SubNumber
say"Area code is:"AreaCode
say"Subscriber number is:"SubNumber
displays:
Area code is: 202Subscriber number is: 123-1234
Interpret
The interpret instruction evaluates its argument as a Rexx statement allowing for evaluation of code formatted at runtime. Uses include passing a function as a parameter, arbitrary precision arithmetic, use of the parse statement with programmatic templates, stemmed arrays, and sparse arrays.[how?] The following example displays 16 and exits.
The Valour software package relied upon Rexx's interpretive ability to implement an OOP environment.[citation needed] Another use was found in an unreleased Westinghouse product called Time Machine that was able to fully recover following an otherwise fatal error.[citation needed]
When a condition is handled (as configured via signal on), the condition can be analyzed via RC which indicates the last error code and SIGL which indicates the line number of the code that triggered the condition.
^EXEC 2 Reference(PDF) (Second ed.). International Business Machines Corporation. April 1982. p. 92. SC24-5219-1. Archived from the original(PDF) on April 2, 2020. Retrieved March 28, 2019.
^ abM. F. Cowlishaw (1984). "The design of the REXX language"(PDF). IBM Systems Journal (PDF). 23 (4). IBM Research: 333. doi:10.1147/sj.234.0326. Retrieved January 23, 2014. Could there be a high astonishment factor associated with the new feature? If a feature is accidentally misapplied by the user and causes what appears to him to be an unpredictable result, that feature has a high astonishment factor and is therefore undesirable. If a necessary feature has a high astonishment factor, it may be necessary to redesign the feature.
^Lundin, Leigh; Woodruff, Mark (April 23, 1987). "T/REXX, a REXX compiler for CMS". U.S. Copyright Office (TXu000295377). Washington, DC: Independent Intelligence Incorporated. Archived from the original on March 3, 2016. Retrieved February 20, 2010.
^Ashley, W David; Flatscher, Rony G; Hessling, Mark; McGuire, Rick; Peedin, Lee; Sims, Oliver; Steinbock, Erich; Wolfers, Jon (January 19, 2024). "8. Rexx Utilities (RexxUtil)"(PDF). Open Object Rexx: Reference(PDF) (5.1.0 ed.). Rexx Language Association. pp. 512–566. Archived(PDF) from the original on May 25, 2024. Retrieved May 26, 2025.
Callaway, Merrill. The ARexx Cookbook: A Tutorial Guide to the ARexx Language on the Commodore Amiga Personal Computer. Whitestone, 1992. ISBN978-0963277305.
Callaway, Merrill. The Rexx Cookbook: A Tutorial Guide to the Rexx Language in OS/2 & Warp on the IBM Personal Computer. Whitestone, 1995. ISBN0-9632773-4-0.
Cowlishaw, Michael. The Rexx Language: A Practical Approach to Programming. Prentice Hall, 1990. ISBN0-13-780651-5.
Cowlishaw, Michael. The NetRexx Language. Prentice Hall, 1997. ISBN0-13-806332-X.
Daney, Charles. Programming in REXX. McGraw-Hill, TX, 1990. ISBN0-07-015305-1.
Ender, Tom. Object-Oriented Programming With Rexx. John Wiley & Sons, 1997. ISBN0-471-11844-3.