HOME

TheInfoList



OR:

Rexx (Restructured Extended Executor) is a programming language that can be interpreted or
compiled In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
. It was developed at IBM by Mike Cowlishaw. It is a structured,
high-level programming language In computer science, a high-level programming language is a programming language with strong Abstraction (computer science), abstraction from the details of the computer. In contrast to low-level programming languages, it may use natural language ...
designed for ease of learning and reading. Proprietary and
open source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
Rexx
interpreters Interpreting is a translational activity in which one produces a first and final target-language output on the basis of a one-time exposure to an expression in a source language. The most common two modes of interpreting are simultaneous interp ...
exist for a wide range of computing platforms;
compiler In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
s exist for IBM
mainframe computer A mainframe computer, informally called a mainframe or big iron, is a computer used primarily by large organizations for critical applications like bulk data processing for tasks such as censuses, industry and consumer statistics, enterpris ...
s. Rexx is a full language that can be used as a scripting, macro language, and application development language. It is often used for processing data and text and generating reports; these similarities with
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offici ...
mean that Rexx works well in
Common Gateway Interface In computing, Common Gateway Interface (CGI) is an interface specification that enables web servers to execute an external program, typically to process user requests. Such programs are often written in a scripting language and are commonly re ...
(CGI) programming and it is indeed used for this purpose. Rexx is the primary scripting language in some operating systems, e.g.
OS/2 OS/2 (Operating System/2) is a series of computer operating systems, initially created by Microsoft and IBM under the leadership of IBM software designer Ed Iacobucci. As a result of a feud between the two companies over how to position OS/2 ...
,
MVS Multiple Virtual Storage, more commonly called MVS, was the most commonly used operating system on the System/370 and System/390 IBM mainframe computers. IBM developed MVS, along with OS/VS1 and SVS, as a successor to OS/360. It is unrelated ...
, VM,
AmigaOS AmigaOS is a family of proprietary native operating systems of the Amiga and AmigaOne personal computers. It was developed first by Commodore International and introduced with the launch of the first Amiga, the Amiga 1000, in 1985. Early versions ...
, and is also used as an internal macro language in some other software, such as
SPF/PC SPF/PC is an MS-DOS-based text editor and file manager designed to have an interface that was familiar to those using mainframe SPF and ISPF. Later Microsoft Windows-based versions were named SPF/SE and SPF/SE 365. A version for OS/2 named SPF/2 ...
,
KEDIT XEDIT is a visual editor for VM/CMS using block mode IBM 3270 terminals. (Line-mode terminals are also supported.) XEDIT is much more line-oriented than modern PC and Unix editors. For example, XEDIT supports automatic line numbers, and ma ...
,
THE ''The'' () is a grammatical article in English, denoting persons or things already mentioned, under discussion, implied or otherwise presumed familiar to listeners, readers, or speakers. It is the definite article in English. ''The'' is the ...
and the ZOC terminal emulator. Additionally, the Rexx language can be used for scripting and macros in any program that uses Windows Scripting Host ActiveX scripting engines languages (e.g. VBScript and JScript) if one of the Rexx engines is installed. 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 PC or pc may refer to: Arts and entertainment * Player character or playable character, a fictional character controlled by a human player, usually in role-playing games or computer games * '' Port Charles'', an American daytime TV soap opera * ...
( 7.0 or
2000 File:2000 Events Collage.png, From left, clockwise: Protests against Bush v. Gore after the 2000 United States presidential election; Heads of state meet for the Millennium Summit; The International Space Station in its infant form as seen from ...
), ArcaOS, and Windows NT 4.0 (Resource Kit: Regina). REXX scripts for CMS share the filetype EXEC with EXEC and EXEC2, and the first line of the script specifies the interpreter to be used. REXX scripts for MVS may be recognized by the low level qualifier EXEC or may be recognized by context and the first line. REXX scripts for OS/2 share the filename extension .cmd with other scripting languages, and the first line of the script specifies the interpreter to be used. REXX macros for REXX-aware applications use extensions determined by the application. In the late 1980s, Rexx became the common scripting language for
IBM Systems Application Architecture Systems Application Architecture (SAA), introduced in 1987, is a set of standards for computer software developed by IBM. The SAA initiative was started in 1987 under the leadership of Earl Wheeler, the "Father of SAA". The intent was to impleme ...
, where it was renamed "SAA Procedure Language REXX". A Rexx script or command is sometimes referred to as an ''EXEC'' in a nod to the CMS file type used for
EXEC Exec or EXEC may refer to: * Executive officer, a person responsible for running an organization * Executive producer, provides finance and guidance for the making of a commercial entertainment product * A family of kit helicopters produced by Rot ...
,
EXEC 2 EXEC 2 is an interpreted, command procedure control, computer scripting language used by the EXEC 2 Processor originally supplied with the CMS component of the IBM Virtual Machine/System Product ( VM/SP) operating system. Relation to EXEC EXEC 2 ...
and REXX scripts on
CP/CMS CP/CMS (Control Program/Cambridge Monitor System) is a discontinued time-sharing operating system of the late 1960s and early 1970s, known for its excellent performance and advanced features. It had three distinct versions: * CP-40/CMS, an im ...
and VM/370 through
z/VM z/VM is the current version in IBM's VM family of virtual machine operating systems. z/VM was first released in October 2000 and remains in active use and development . It is directly based on technology and concepts dating back to the 1960s, wi ...
.


Features

Rexx has the following characteristics and features: * Simple syntax * The ability to route commands to multiple environments * The ability to support functions, procedures and commands associated with a specific invoking environment. * A built-in stack, with the ability to interoperate with the host stack if there is one. * Small instruction set containing just two dozen instructions * Freeform syntax * Case-insensitive tokens, including variable names *
Character string In computer programming, a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. The latter may allow its elements to be mutated and the length changed, or it may be fixed (after creation). ...
basis * Dynamic data typing, no declarations * No reserved keywords, except in local context * No include file facilities * Arbitrary numerical precision * Decimal arithmetic,
floating-point In computing, floating-point arithmetic (FP) is arithmetic that represents real numbers approximately, using an integer with a fixed precision, called the significand, scaled by an integer exponent of a fixed base. For example, 12.345 can b ...
* A rich selection of built-in functions, especially string and word processing * Automatic storage management * Crash protection * Content addressable data structures *
Associative array In computer science, an associative array, map, symbol table, or dictionary is an abstract data type that stores a collection of (key, value) pairs, such that each possible key appears at most once in the collection. In mathematical terms an ...
s * 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 Rexx has just twenty-three, largely self-evident, instructions (such as call, parse, and select) with minimal punctuation and formatting requirements. It is essentially an almost
free-form language In computer programming, a free-form language is a programming language in which the positioning of characters on the page in program text is insignificant. Program text does not need to be placed in specific columns as on old punched card syst ...
with only one data-type, the character string; this philosophy means that all data are visible (symbolic) and debugging and tracing are simplified. Rexx's syntax looks similar to
PL/I PL/I (Programming Language One, pronounced and sometimes written PL/1) is a procedural, imperative computer programming language developed and published by IBM. It is designed for scientific, engineering, business and system programming. I ...
, but has fewer notations; this makes it harder to parse (by program) but easier to use, except for cases where PL/I habits may lead to surprises. One of the REXX design goals was the
principle of least astonishment The principle of least astonishment (POLA), aka principle of least surprise (alternatively a law or rule), applies to user interface and software design. It proposes that a component of a system should behave in a way that most users will expect it ...
.


History


pre-1990

Rexx was designed and first implemented, in
assembly language In computer programming, assembly language (or assembler language, or symbolic machine code), often referred to simply as Assembly and commonly abbreviated as ASM or asm, is any low-level programming language with a very strong correspondence be ...
, as an 'own-time' project between 20 March 1979 and mid-1982 by Mike Cowlishaw of IBM, originally as a
scripting programming language A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually Interpreter (computing), interpreted at Runtime (program li ...
to replace the languages
EXEC Exec or EXEC may refer to: * Executive officer, a person responsible for running an organization * Executive producer, provides finance and guidance for the making of a commercial entertainment product * A family of kit helicopters produced by Rot ...
and
EXEC 2 EXEC 2 is an interpreted, command procedure control, computer scripting language used by the EXEC 2 Processor originally supplied with the CMS component of the IBM Virtual Machine/System Product ( VM/SP) operating system. Relation to EXEC EXEC 2 ...
. It was designed to be a macro or scripting language for any system. As such, Rexx is considered a precursor to
Tcl TCL or Tcl or TCLs may refer to: Business * TCL Technology, a Chinese consumer electronics and appliance company **TCL Electronics, a subsidiary of TCL Technology * Texas Collegiate League, a collegiate baseball league * Trade Centre Limited ...
and
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
. Rexx was also intended by its creator to be a simplified and easier to learn version of the
PL/I PL/I (Programming Language One, pronounced and sometimes written PL/1) is a procedural, imperative computer programming language developed and published by IBM. It is designed for scientific, engineering, business and system programming. I ...
programming language. However, some differences from PL/I may trip up the unwary. It was first described in public at the SHARE 56 conference in Houston, Texas, in 1981, where customer reaction, championed by Ted Johnston of
SLAC SLAC National Accelerator Laboratory, originally named the Stanford Linear Accelerator Center, is a United States Department of Energy National Laboratory operated by Stanford University under the programmatic direction of the U.S. Departme ...
, led to it being shipped as an IBM product in 1982. Over the years IBM included Rexx in almost all of its operating systems (
VM/CMS VM (often: VM/CMS) is a family of IBM virtual machine operating systems used on IBM mainframes System/370, System/390, zSeries, System z and compatible systems, including the Hercules emulator for personal computers. The following versions ...
, MVS TSO/E, IBM i, VSE/ESA,
AIX Aix or AIX may refer to: Computing * AIX, a line of IBM computer operating systems *An Alternate Index, for a Virtual Storage Access Method Key Sequenced Data Set * Athens Internet Exchange, a European Internet exchange point Places Belgi ...
,
PC DOS PC or pc may refer to: Arts and entertainment * Player character or playable character, a fictional character controlled by a human player, usually in role-playing games or computer games * '' Port Charles'', an American daytime TV soap opera * ...
, and
OS/2 OS/2 (Operating System/2) is a series of computer operating systems, initially created by Microsoft and IBM under the leadership of IBM software designer Ed Iacobucci. As a result of a feud between the two companies over how to position OS/2 ...
), and has made versions available for
Novell NetWare NetWare is a discontinued computer network operating system developed by Novell, Inc. It initially used cooperative multitasking to run various services on a personal computer, using the IPX network protocol. The original NetWare product in ...
,
Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
,
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
, and
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
. The first non-IBM version was written for
PC DOS PC or pc may refer to: Arts and entertainment * Player character or playable character, a fictional character controlled by a human player, usually in role-playing games or computer games * '' Port Charles'', an American daytime TV soap opera * ...
by Charles Daney in 1984/5 and marketed by the Mansfield Software Group (founded by Kevin J. Kearney in 1986). The first compiler version appeared in 1987, written for CMS by Lundin and Woodruff. Other versions have also been developed for
Atari Atari () is a brand name that has been owned by several entities since its inception in 1972. It is currently owned by French publisher Atari SA through a subsidiary named Atari Interactive. The original Atari, Inc. (1972–1992), Atari, Inc., ...
,
AmigaOS AmigaOS is a family of proprietary native operating systems of the Amiga and AmigaOne personal computers. It was developed first by Commodore International and introduced with the launch of the first Amiga, the Amiga 1000, in 1985. Early versions ...
,
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
(many variants),
Solaris Solaris may refer to: Arts and entertainment Literature, television and film * ''Solaris'' (novel), a 1961 science fiction novel by Stanisław Lem ** ''Solaris'' (1968 film), directed by Boris Nirenburg ** ''Solaris'' (1972 film), directed by ...
, DEC,
Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
,
Windows CE Windows Embedded Compact, formerly Windows Embedded CE, Windows Powered and Windows CE, is an operating system subfamily developed by Microsoft as part of its Windows Embedded family of products. Unlike Windows Embedded Standard, which is base ...
,
Pocket PC A Pocket PC (P/PC, PPC) is a class of personal digital assistant (PDA) that runs the Windows Mobile or Windows Embedded Compact operating system that has some of the abilities of modern desktop PCs. The name was introduced by Microsoft in 2000 ...
,
DOS DOS is shorthand for the MS-DOS and IBM PC DOS family of operating systems. DOS may also refer to: Computing * Data over signalling (DoS), multiplexing data onto a signalling channel * Denial-of-service attack (DoS), an attack on a communicat ...
,
Palm OS Palm OS (also known as Garnet OS) was a mobile operating system initially developed by Palm, Inc., for personal digital assistants (PDAs) in 1996. Palm OS was designed for ease of use with a touchscreen-based graphical user interface. It is provi ...
,
QNX QNX ( or ) is a commercial Unix-like real-time operating system, aimed primarily at the embedded systems market. QNX was one of the first commercially successful microkernel operating systems. The product was originally developed in the early ...
,
OS/2 OS/2 (Operating System/2) is a series of computer operating systems, initially created by Microsoft and IBM under the leadership of IBM software designer Ed Iacobucci. As a result of a feud between the two companies over how to position OS/2 ...
,
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
,
BeOS BeOS is an operating system for personal computers first developed by Be Inc. in 1990. It was first written to run on BeBox hardware. BeOS was positioned as a multimedia platform that could be used by a substantial population of desktop users a ...
,
EPOC32 EPOC is a mobile operating system developed by Psion, a British company founded in 1980. It began as a 16-bit operating system (OS) for Psion's own x86-compatible devices, and was later replaced by a 32-bit system for x86 and ARM. Psion license ...
/
Symbian Symbian is a discontinued mobile operating system A mobile operating system is an operating system for mobile phones, tablets, smartwatches, smartglasses, or other non-laptop personal mobile computing devices. While computers such as typic ...
,
AtheOS Syllable Desktop is a discontinued free and open-source operating system for Pentium and compatible processors. Its purpose is to create an easy-to-use desktop operating system for the home and small office user. It was forked from the stagnant ...
,
OpenVMS OpenVMS, often referred to as just VMS, is a multi-user, multiprocessing and virtual memory-based operating system. It is designed to support time-sharing, batch processing, transaction processing and workstation applications. Customers using Ope ...
, Apple
Macintosh The Mac (known as Macintosh until 1999) is a family of personal computers designed and marketed by Apple Inc., Apple Inc. Macs are known for their ease of use and minimalist designs, and are popular among students, creative professionals, and ...
, and
Mac OS X macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
. The
Amiga Amiga is a family of personal computers introduced by Commodore in 1985. The original model is one of a number of mid-1980s computers with 16- or 32-bit processors, 256 KB or more of RAM, mouse-based GUIs, and significantly improved graphi ...
version of Rexx, called
ARexx ARexx is an implementation of the Rexx language for the Amiga, written in 1987 by William S. Hawes, with a number of Amiga-specific features beyond standard REXX facilities. Like most REXX implementations, ARexx is an interpreted language. Program ...
, was included with AmigaOS 2 onwards and was popular for scripting as well as application control. Many Amiga applications have an "ARexx port" built into them which allows control of the application from Rexx. One single Rexx script could even switch between different Rexx ports in order to control several running 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. Several
freeware Freeware is software, most often proprietary, that is distributed at no monetary cost to the end user. There is no agreed-upon set of rights, license, or EULA that defines ''freeware'' unambiguously; every publisher defines its own rules for the f ...
versions of Rexx are available. In 1992, the two most widely used
open-source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
ports appeared: Ian Collier's REXX/imc for Unix and Anders Christensen's Regina (later adopted by Mark Hessling) for Windows and Unix
BREXX
is well known for WinCE and Pocket PC platforms, and has been "back-ported" to VM/370 and
MVS Multiple Virtual Storage, more commonly called MVS, was the most commonly used operating system on the System/370 and System/390 IBM mainframe computers. IBM developed MVS, along with OS/VS1 and SVS, as a successor to OS/360. It is unrelated ...
. OS/2 has a visual development system from Watcom
VX-REXX VX-REXX is a highly extensible REXX GUI development system for OS/2 developed by Watcom and initially released in 1993. Much of the new code in eComStation and ArcaOS has been written using VX-REXX. Though REXX is itself a 3GL, the VX-REXX inter ...
. 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 NetRexx is an open source, originally IBM's, variant of the REXX programming language to run on the Java virtual machine. It supports a classic REXX syntax, with no reserved keywords, along with considerable additions to support object-oriented ...
: compiles to
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
byte-code Bytecode (also called portable code or p-code) is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normall ...
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. * Object REXX: an
object-oriented Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of pro ...
generally upwards-compatible version of Rexx. In 1996
American National Standards Institute The American National Standards Institute (ANSI ) is a private non-profit organization that oversees the development of voluntary consensus standards for products, services, processes, systems, and personnel in the United States. The organi ...
(ANSI) published a standard for Rexx: ANSI X3.274–1996 "Information Technology – Programming Language REXX". 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 In computing, the Common Public License (CPL) is a free software / open-source software license published by IBM. The Free Software Foundation and Open Source Initiative have approved the license terms of the CPL. Definition The CPL has the stat ...
. Recent releases of Object REXX contain an ActiveX
Windows Scripting Host The Microsoft Windows Script Host (WSH) (formerly named Windows Scripting Host) is an automation technology for Microsoft Windows operating systems that provides scripting abilities comparable to batch files, but with a wider range of supported f ...
(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 Visual Basic is a name for a family of programming languages from Microsoft. It may refer to: * Visual Basic .NET (now simply referred to as "Visual Basic"), the current version of Visual Basic launched in 2002 which runs on .NET * Visual Basic (cl ...
and
JScript JScript is Microsoft's legacy dialect of the ECMAScript standard that is used in Microsoft's Internet Explorer 11 and older. JScript is implemented as an Active Scripting engine. This means that it can be "plugged in" to OLE Automation applicati ...
are implemented by the default WSH installation and
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offici ...
,
Tcl TCL or Tcl or TCLs may refer to: Business * TCL Technology, a Chinese consumer electronics and appliance company **TCL Electronics, a subsidiary of TCL Technology * Texas Collegiate League, a collegiate baseball league * Trade Centre Limited ...
,
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (pro ...
third-party scripting engines. REXX was listed in the
TIOBE index The TIOBE programming community index is a measure of popularity of programming languages, created and maintained by TIOBE Software BV, based in Eindhoven, the Netherlands. TIOBE stands for ''The Importance of Being Earnest'', the title of an 18 ...
as one of the fifty languages in its top 100 not belonging to the top 50. 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.


Toolkits

Rexx/Tk, a toolkit for graphics to be used in Rexx programmes in the same fashion as
Tcl/Tk Tk is a free and open-source, cross-platform widget toolkit that provides a library of basic elements of GUI widgets for building a graphical user interface (GUI) in many programming languages. Tk provides a number of widgets commonly needed to ...
is widely available. A Rexx IDE, RxxxEd, has been developed for Windows. 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 under all of them as well as DOS.


Spelling and capitalization

Originally the language was called ''Rex'' (''Reformed Executor''); the extra "X" was added to avoid collisions with other products' names. REX was originally all uppercase because the mainframe code was uppercase oriented. The style in those days was to have all-caps names, partly because almost all code was still all-caps then. For the product it became REXX, and both editions of Mike Cowlishaw's book use all-caps. The expansion to ''REstructured eXtended eXecutor'' was used for the system product in 1984.


Syntax


Looping

The loop control structure in Rexx begins with a DO and ends with an END but comes in several varieties. NetRexx uses the keyword LOOP instead of DO for looping, while ooRexx treats LOOP and DO as equivalent when looping.


Conditional loops

Rexx supports a variety of traditional structured-programming loops while testing a condition either before (do while) or after (do until) the list of instructions are executed: do while ondition nstructions end do until ondition nstructions end


Repetitive loops

Like most languages, Rexx can loop while incrementing an index variable and stop when a limit is reached: do index = start o limit y increment or count nstructions end The increment may be omitted and defaults to 1. The limit can also be omitted, which makes the loop continue forever. Rexx 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: do expression nstructions end Rexx can even loop until the program is terminated: do forever nstructions end A program can break out of the current loop with the leave instruction, which is the normal way to exit a do forever loop, or can short-circuit it with the iterate instruction.


Combined loops

Like
PL/I PL/I (Programming Language One, pronounced and sometimes written PL/1) is a procedural, imperative computer programming language developed and published by IBM. It is designed for scientific, engineering, business and system programming. I ...
, Rexx allows both conditional and repetitive elements to be combined in the same loop: do index = start o limit y increment or count hile condition nstructions end do expression ntil condition nstructions end


Conditionals

Testing conditions with IF: if onditionthen do nstructions end else do nstructions end The ELSE clause is optional. For single instructions, DO and END can also be omitted: if onditionthen nstruction else nstruction Indentation is optional, but it helps improve the readability.


Testing for multiple conditions

SELECT is Rexx's CASE structure, like many other constructs derived from
PL/I PL/I (Programming Language One, pronounced and sometimes written PL/1) is a procedural, imperative computer programming language developed and published by IBM. It is designed for scientific, engineering, business and system programming. I ...
. Like some implementations of CASE constructs in other dynamic languages, Rexx's WHEN clauses specify full conditions, which need not be related to each other. In that, they are more like cascaded sets of IF-THEN-ELSEIF-THEN-...-ELSE code than they are like the C or Java switch statement. select when onditionthen nstructionor NOP when onditionthen do nstructionsor NOP end otherwise nstructionsor NOP end The NOP instruction performs "no operation", and is used when the programmer wishes to do nothing in a place where one or more instructions would be required. The OTHERWISE clause is optional. If omitted and no WHEN conditions are met, then the SYNTAX condition is raised.


Simple variables

Variables in Rexx 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: say hello /* => HELLO */ hello = 25 say hello /* => 25 */ hello = "say 5 + 3" say hello /* => say 5 + 3 */ interpret hello /* => 8 */ drop hello say hello /* => HELLO */


Compound variables

Unlike many other programming languages, classic Rexx has no direct support for arrays of variables addressed by a numerical index. Instead it provides ''compound variables''. A compound variable consists of a stem followed by a tail. A . (dot) is used to join the stem to the tail. If the tails used are numeric, it is easy to produce the same effect as an array. do i = 1 to 10 stem.i = 10 - i end Afterwards the following variables with the following values exist: stem.1 = 9, stem.2 = 8, stem.3 = 7... Unlike arrays, the index for a stem variable is not required to have an integer value. For example, the following code is valid: i = 'Monday' stem.i = 2 In Rexx it is also possible to set a default value for a stem. stem. = 'Unknown' stem.1 = 'USA' stem.44 = 'UK' stem.33 = 'France' After these assignments the term stem.3 would produce 'Unknown'. The whole stem can also be erased with the DROP statement. drop stem. This also has the effect of removing any default value set previously. By convention (and not as 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: add_word: procedure expose dictionary. parse arg w n = dictionary.0 + 1 dictionary.n = w dictionary.0 = n return It is also possible to have multiple elements in the tail of a compound variable. For example: m = 'July' d = 15 y = 2005 day.y.m.d = 'Friday' Multiple numerical tail elements can be used to provide the effect of a multi-dimensional array. Features similar to Rexx compound variables are found in many other languages (including
associative array In computer science, an associative array, map, symbol table, or dictionary is an abstract data type that stores a collection of (key, value) pairs, such that each possible key appears at most once in the collection. In mathematical terms an as ...
s in
AWK AWK (''awk'') is a domain-specific language designed for text processing and typically used as a data extraction and reporting tool. Like sed and grep, it is a filter, and is a standard feature of most Unix-like operating systems. The AWK lang ...
, hashes in
Perl Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offici ...
and Hashtables in
Java Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
). Most of these languages provide an instruction to iterate over all the keys (or ''tails'' in Rexx terms) of such a construct, but this is lacking in classic Rexx. Instead it is necessary to keep auxiliary lists of tail values as appropriate. For example, in a program to count words the following procedure might be used to record each occurrence of a word. add_word: procedure expose count. word_list parse arg w . count.w = count.w + 1 /* assume count. has been set to 0 */ if count.w = 1 then word_list = word_list w return and then later: do i = 1 to words(word_list) w = word(word_list,i) say w count.w end At the cost of some clarity it is possible to combine these techniques into a single stem: add_word: procedure expose dictionary. parse arg w . dictionary.w = dictionary.w + 1 if dictionary.w = 1 /* assume dictionary. = 0 */ then do n = dictionary.0+1 dictionary.n = w dictionary.0 = n end return and later: do i = 1 to dictionary.0 w = dictionary.i say i w dictionary.w end Rexx provides no safety net here, so if one of the words happens to be a whole number less than dictionary.0 this technique will fail mysteriously. Recent implementations of Rexx, including IBM's Object REXX and the open source implementations like ooRexx include a new
language construct In computer programming, a language construct is a syntactically allowable part of a program that may be formed from one or more lexical tokens in accordance with the rules of the programming language. The term "language construct" is often used ...
to simplify iteration over the value of a stem, or over another collection object such as an array, table or list. do i over stem. say i '-->' stem.i end


Keyword instructions


PARSE

The PARSE instruction is particularly powerful; it combines some useful string-handling functions. Its syntax is: parse pperorigin
emplate Earth Lord Earth Sentry Earth Sentry (John Foster) was created by Tom DeFalco and Ron Frenz, and first appeared in ''A-Next'' #2 (1999) in the MC2 universe. When John and his father Bill were investigating a UFO crash site, they discovered ...
where ''origin'' specifies the source: * 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) * value (an expression) with: the keyword with is required to indicate where the expression ends * var (a variable) * version (version/release number) and ''template'' can be: * list of variables * column number delimiters * literal delimiters upper is optional; if specified, data will be converted to upper case before parsing. Examples: Using a list of variables as template myVar = "John Smith" parse var myVar firstName lastName say "First name is:" firstName say "Last name is:" lastName displays the following:
 First name is: John
 Last name is: Smith
Using a delimiter as template: myVar = "Smith, John" parse var myVar LastName "," FirstName say "First name is:" firstName say "Last name is:" lastName also displays the following:
 First name is: John
 Last name is: Smith
Using column number delimiters: myVar = "(202) 123-1234" parse var MyVar 2 AreaCode 5 7 SubNumber say "Area code is:" AreaCode say "Subscriber number is:" SubNumber displays the following:
 Area code is: 202
 Subscriber number is: 123-1234
A template can use a combination of variables, literal delimiters, and column number delimiters.


INTERPRET

The INTERPRET instruction evaluates its argument and treats its value as a Rexx statement. Sometimes INTERPRET is the clearest way to perform a task, but it is often used where clearer code is possible using, e.g., value(). Other uses of INTERPRET are Rexx's (decimal) arbitrary precision arithmetic (including fuzzy comparisons), use of the PARSE statement with programmatic templates, stemmed arrays, and sparse arrays. /* demonstrate INTERPRET with square(4) => 16 */ X = 'square' interpret 'say' X , , '(4) ; exit' SQUARE: return arg(1)**2 This displays 16 and exits. Because variable contents in Rexx are strings, including rational numbers with exponents and even entire programs, Rexx offers to interpret strings as evaluated expressions. This feature could be used to pass functions as ''function parameters'', such as passing SIN or COS to a procedure to calculate integrals. Rexx offers only basic math functions like ABS, DIGITS, MAX, MIN, SIGN, RANDOM, and a complete set of hex plus binary conversions with bit operations. More complex functions like SIN were implemented from scratch or obtained from third party external
libraries A library is a collection of materials, books or media that are accessible for use and not just for display purposes. A library provides physical (hard copies) or digital access (soft copies) materials, and may be a physical location or a vir ...
. Some external libraries, typically those implemented in traditional languages, did not support extended precision. Later versions (non-classic) support CALL variable constructs. Together with the built-in function VALUE, CALL can be used in place of many cases of INTERPRET. This is a classic program: /* terminated by input "exit" or similar */ do forever ; interpret linein() ; end A slightly more sophisticated "Rexx calculator": X = 'input BYE to quit' do until X = 'BYE' ; interpret 'say' X ; pull X ; end PULL is shorthand for parse upper pull. Likewise, ARG is shorthand for parse upper arg. The power of the INTERPRET instruction had other uses. The Valour software package relied upon Rexx's interpretive ability to implement an OOP environment. Another use was found in an unreleased Westinghouse product called ''Time Machine'' that was able to fully recover following a fatal error.


NUMERIC

say digits() fuzz() form() /* => 9 0 SCIENTIFIC */ say 999999999+1 /* => 1.000000000E+9 */ numeric digits 10 /* only limited by available memory */ say 999999999+1 /* => 1000000000 */ say 0.9999999999=1 /* => 0 (false) */ numeric fuzz 3 say 0.99999999=1 /* => 1 (true) */ say 0.99999999

1 /* => 0 (false) */ say 100*123456789 /* => 1.23456789E+10 */ numeric form engineering say 100*123456789 /* => 12.34567890E+9 */ say 53 // 7 /* => 4 (rest of division)*/


SIGNAL

The SIGNAL instruction is intended for abnormal changes in the flow of control (see the next section). However, it can be misused and treated like the
GOTO GoTo (goto, GOTO, GO TO or other case combinations, depending on the programming language) is a statement found in many computer programming languages. It performs a one-way transfer of control to another line of code; in contrast a function ca ...
statement found in other languages (although it is not strictly equivalent, because it terminates loops and other constructs). This can produce difficult-to-read code.


Error handling and exceptions

It is possible in Rexx to intercept and deal with errors and other exceptions, using the SIGNAL instruction. There are seven system conditions: ERROR, FAILURE, HALT, NOVALUE, NOTREADY, LOSTDIGITS and SYNTAX. Handling of each can be switched on and off in the source code as desired. The following program will run until terminated by the user: signal on halt; do a = 1 say a do 100000 /* a delay */ end end halt: say "The program was stopped by the user" exit A signal on novalue statement intercepts uses of undefined variables, which would otherwise get their own (upper case) name as their value. Regardless of the state of the NOVALUE condition, the status of a variable can always be checked with the built-in function SYMBOL returning VAR for defined variables. The VALUE function can be used to get the value of variables without triggering a NOVALUE condition, but its main purpose is to read and set
environment Environment most often refers to: __NOTOC__ * Natural environment, all living and non-living things occurring naturally * Biophysical environment, the physical and biological factors along with their chemical interactions that affect an organism or ...
variables, similar to
POSIX The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming interf ...
getenv and putenv.


Conditions

; ERROR : Positive RC from a system command ; FAILURE : Negative RC for a system command (e.g. command doesn't exist) ; HALT : Abnormal termination ; NOVALUE : An unset variable was referenced ; NOTREADY : Input or output error (e.g. read attempts beyond end of file) ; SYNTAX : Invalid program syntax, or some other error condition ; LOSTDIGITS : Significant digits are lost (ANSI Rexx, not in TRL second edition) When a condition is handled by SIGNAL ON, the SIGL and RC system variables can be analyzed to understand the situation. RC contains the Rexx error code and SIGL contains the line number where the error arose. Beginning with Rexx version 4 conditions can get names, and there's also a CALL ON construct. That's handy if external functions do not necessarily exist: ChangeCodePage: procedure /* protect SIGNAL settings */ signal on syntax name ChangeCodePage.Trap return SysQueryProcessCodePage() ChangeCodePage.Trap: return 1004 /* windows-1252 on OS/2 */


See also

*
ISPF In computing, Interactive System Productivity Facility (ISPF) is a software product for many historic IBM mainframe operating systems and currently the z/OS and z/VM operating systems that run on IBM mainframes. It includes a screen editor, the us ...
*
XEDIT XEDIT is a visual editor for VM/CMS using block mode IBM 3270 terminals. (Line-mode terminals are also supported.) XEDIT is much more line-oriented than modern PC and Unix editors. For example, XEDIT supports automatic line numbers, and ma ...
*
Comparison of computer shells A command shell is a command-line interface to interact with and manipulate a computer's operating system. General characteristics Interactive features Background execution Background execution allows a shell to run a command without us ...
*
Comparison of programming languages Programming languages are used for controlling the behavior of a machine (often a computer). Like natural languages, programming languages follow the rules for syntax and semantics. There are thousands of programming languages and new ones are c ...


Notes


References


Further reading

* Callaway, Merrill. ''The ARexx Cookbook: A Tutorial Guide to the ARexx Language on the Commodore Amiga Personal Computer''. Whitestone, 1992. . * Callaway, Merrill. ''The Rexx Cookbook: A Tutorial Guide to the Rexx Language in OS/2 & Warp on the IBM Personal Computer''. Whitestone, 1995. . * Cowlishaw, Michael. ''The Rexx Language: A Practical Approach to Programming''. Prentice Hall, 1990. . * Cowlishaw, Michael. ''The NetRexx Language''. Prentice Hall, 1997. . * Daney, Charles. ''Programming in REXX''. McGraw-Hill, TX, 1990. . * Ender, Tom. ''Object-Oriented Programming With Rexx''. John Wiley & Sons, 1997. . * Fosdick, Howard. ''Rexx Programmer's Reference''. Wiley/Wrox, 2005. . * Gargiulo, Gabriel. ''REXX with OS/2, TSO, & CMS Features''. MVS Training, 1999 (third edition 2004). . * Goldberg, Gabriel and Smith, Philip H. ''The Rexx Handbook ''. McGraw-Hill, TX, 1992. . * Goran, Richard K. ''REXX Reference Summary Handbook''. CFS Nevada, Inc.,1997. . * IBM Redbooks. ''Implementing Rexx Support in Sdsf''. Vervante, 2007. . * Kiesel, Peter C. ''Rexx: Advanced Techniques for Programmers''. McGraw-Hill, TX, 1992. . * Marco, Lou ''ISPF/REXX Development for Experienced Programmers''. CBM Books, 1995. * O'Hara, Robert P. and Gomberg, David Roos. ''Modern Programming Using Rexx''. Prentice Hall, 1988. . * Rudd, Anthony S. 'Practical Usage of TSO REXX'. CreateSpace, 2012. . * Schindler, William. ''Down to Earth Rexx''. Perfect Niche Software, 2000. .


External links


Mike Cowlishaw's home page

REXX language page
at IBM
REXX Language Association

Rexx programming language
at
Open Hub Black Duck Open Hub, formerly Ohloh, is a website which provides a web services suite and online community platform that aims to index the open-source software development community. It was founded by former Microsoft managers Jason Allen and Sc ...
{{Authority control IBM software Scripting languages Text-oriented programming languages Command shells IBM mainframe operating systems Cross-platform software Programming languages created in 1979 Rexx