HOME

TheInfoList



OR:

Rexx (restructured extended executor) is a
high-level programming language 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 ''elements'', be ea ...
developed at
IBM International Business Machines Corporation (using the trademark IBM), nicknamed Big Blue, is an American Multinational corporation, multinational technology company headquartered in Armonk, New York, and present in over 175 countries. It is ...
by Mike Cowlishaw. Both proprietary and
open source Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
Rexx interpreters exist for a wide range of
computing platform A computing platform, digital platform, or software platform is the infrastructure on which software is executed. While the individual components of a computing platform may be obfuscated under layers of abstraction, the ''summation of the requi ...
s, and
compiler In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primaril ...
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, enterprise ...
s. Rexx is used for scripting, application macros and application development. As a general purpose scripting language, Rexx is considered a precursor to Tcl and Python. Rexx is supported in a variety of environments. It is the primary scripting language in some
operating system An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ...
s including
OS/2 OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
, MVS, 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 used for macros in some software including SPF/PC, KEDIT,
THE ''The'' is a grammatical article in English, denoting nouns that are already or about to be mentioned, under discussion, implied or otherwise presumed familiar to listeners, readers, or speakers. It is the definite article in English. ''The ...
and ZOC. With an engine installed, Rexx can be used for scripting and macros in programs that use a Windows Scripting Host
ActiveX ActiveX is a deprecated software framework created by Microsoft that adapts its earlier Component Object Model (COM) and Object Linking and Embedding (OLE) technologies for content downloaded from a network, particularly from the World Wide W ...
scripting engine (such as VBScript or
JScript JScript is Microsoft's legacy dialect of the ECMAScript standard that is used in Microsoft's Internet Explorer web browser and HTML Applications, and as a standalone Windows scripting language. JScript is implemented as an Active Scripting eng ...
). 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 2000 was designated as the International Year for the Culture of Peace and the World Mathematics, Mathematical Year. Popular culture holds the year 2000 as the first year of the 21st century and the 3rd millennium, because of a tende ...
),
ArcaOS ArcaOS is a Proprietary software, proprietary operating system based on OS/2, developed and marketed by Arca Noae, LLC under license from IBM. It was first released in 2017 and builds on OS/2 Warp 4.52 by adding support for new hardware, fixing ...
, 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 CMS EXEC, and EXEC 2 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 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 Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
, 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, . An expansion that matches the abbreviation, ''REstructured eXtended eXecutor'', was used for the system product in 1984. 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 * 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 facility *
Arbitrary-precision arithmetic In computer science, arbitrary-precision arithmetic, also called bignum arithmetic, multiple-precision arithmetic, or sometimes infinite-precision arithmetic, indicates that calculations are performed on numbers whose digits of precision are po ...
* Decimal arithmetic,
floating-point In computing, floating-point arithmetic (FP) is arithmetic on subsets of real numbers formed by a ''significand'' (a Sign (mathematics), signed sequence of a fixed number of digits in some Radix, base) multiplied by an integer power of that ba ...
* 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, key-value store, 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 math ...
* 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 In computer science and computer programming, a data type (or simply type) is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these ...
, the character string. Some claim that such simplicities make Rexx relatively easy to debug. Some claim that Rexx code looks similar to
PL/I PL/I (Programming Language One, pronounced and sometimes written PL/1) is a procedural, imperative computer programming language initially developed by IBM. It is designed for scientific, engineering, business and system programming. It has b ...
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.


History


pre1990

On his own time, Mike Cowlishaw developed the language and an interpreter for it in
assembly language In computing, assembly language (alternatively 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 bet ...
between 20 March 1979 and mid-1982 with the intent to replace the languages EXEC and EXEC 2. Mike also intended Rexx to be a simplified and easier to learn version of
PL/I PL/I (Programming Language One, pronounced and sometimes written PL/1) is a procedural, imperative computer programming language initially developed by IBM. It is designed for scientific, engineering, business and system programming. It has b ...
, 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, where customer reaction, championed by Ted Johnston of SLAC, 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, MVS TSO/E, IBM OS/400, VSE/ESA, MUSIC/SP, AIX, PC DOS, and
OS/2 OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
), 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 Internetwork Packet Exchange, IPX network protocol. The f ...
,
Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
,
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
, and
Linux Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
. The first non-IBM version was written for PC DOS by Charles Daney in 1984/5 and marketed by the Mansfield Software Group (founded by Kevin J. Kearney in 1986). The first Rexx compiler 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 holding company Atari SA (formerly Infogrames) and its focus is on "video games, consumer hardware, licensing and bl ...
,
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, multi-user 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, a ...
(many variants), Solaris, DEC,
Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
, Windows CE, Pocket PC, DOS,
Palm OS Palm OS (also known as Garnet OS) is a discontinued 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. ...
, QNX,
OS/2 OS/2 is a Proprietary software, proprietary computer operating system for x86 and PowerPC based personal computers. It was created and initially developed jointly by IBM and Microsoft, under the leadership of IBM software designer Ed Iacobucci, ...
,
Linux Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
, BeOS, EPOC32/ Symbian, AtheOS,
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 Op ...
, Apple
Macintosh Mac is a brand of personal computers designed and marketed by Apple Inc., Apple since 1984. The name is short for Macintosh (its official name until 1999), a reference to the McIntosh (apple), McIntosh apple. The current product lineup inclu ...
, and
Mac OS X macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
.
ARexx ARexx is a Rexx interpreter for Amiga, written in 1987 by William S. Hawes, with a number of Amiga-specific features beyond standard Rexx. An ARexx script can communicate with software that implements an ''ARexx port''. An Amiga application can ...
, a Rexx interpreter for
Amiga Amiga is a family of personal computers produced by Commodore International, Commodore from 1985 until the company's bankruptcy in 1994, with production by others afterward. The original model is one of a number of mid-1980s computers with 16-b ...
, 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 Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
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. 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 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 pr ...
: compiles to
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
byte-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. *
Object REXX Object REXX is a high-level, general-purpose, interpreted, object-oriented ( class-based) programming language. Today it is generally referred to as ooRexx (short for "Open Object Rexx"), which is the maintained and direct open-source success ...
: an object-oriented generally upwards-compatible version of Rexx. In 1996 the
American National Standards Institute The American National Standards Institute (ANSI ) is a private nonprofit organization that oversees the development of voluntary consensus standards for products, services, processes, systems, and personnel in the United States. The organiz ...
(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 Object REXX is a high-level, general-purpose, interpreted, object-oriented ( class-based) programming language. Today it is generally referred to as ooRexx (short for "Open Object Rexx"), which is the maintained and direct open-source success ...
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 Visual Basic is a name for a family of programming languages from Microsoft. It may refer to: * Visual Basic (.NET), the current version of Visual Basic launched in 2002 which runs on .NET * Visual Basic (classic), the original Visual Basic suppo ...
and
JScript JScript is Microsoft's legacy dialect of the ECMAScript standard that is used in Microsoft's Internet Explorer web browser and HTML Applications, and as a standalone Windows scripting language. JScript is implemented as an Active Scripting eng ...
are implemented by the default WSH installation and
Perl Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language". Perl was developed ...
, Tcl, Python third-party scripting engines. In January 2018 the TIOBE index listed Rexx at position 30. 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.


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. *Rexx/Tk a toolkit for graphics to be used in Rexx programmes in the same fashion as Tcl/Tk is widely available. *RexxEd an
integrated development environment An integrated development environment (IDE) is a Application software, software application that provides comprehensive facilities for software development. An IDE normally consists of at least a source-code editor, build automation tools, an ...
(IDE) for Rexx was developed for
Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
. *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.


Syntax


Instruction types

Rexx has three instruction types *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: if foo=bar then do i=1;j=3 end else do i=2;j=4 end


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: do ''expression'' 'instructions'' end


Controlled Repetitive Loops

A loop can increment a variable and stop when a limit is reached. do ''index''=''start'' ''to ''limit'' ''by ''increment'' ''for ''count'' '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; e.g.:do i=1 while i<=3; say i; end do ''index''=''start'' ''to ''limit'' ''by increment ''for ''count'' ''while ''condition'' 'instructions'' end do ''expression'' ''until ''condition'' 'instructions'' end


Conditional

The language provides for conditional execution via if, then and else for a group delimited by do and end. if 'condition''then do 'instructions'' end else do '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 . 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. select when 'condition''then 'instruction'' or nop when 'condition''then do 'instructions'' or nop end otherwise '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: 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 */


Evaluation

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
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 application programming interfaces (APIs), along with comm ...
getenv 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. The following code defines variables stem.1 = 9, stem.2 = 8, stem.3 = 7... do i = 1 to 10 stem.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. stem. = 'Unknown' stem.1 = 'USA' stem.44 = 'UK' stem.33 = 'France' 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. drop stem. 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: add_word: procedure expose dictionary. parse arg w n = dictionary.0 + 1 dictionary.n = w dictionary.0 = n return A stem can have multiple tails. 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 the compound variable are found in other languages including
associative array In computer science, an associative array, key-value store, 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 math ...
s in AWK, hashes in
Perl Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language". Perl was developed ...
and
hash table In computer science, a hash table is a data structure that implements an associative array, also called a dictionary or simply map; an associative array is an abstract data type that maps Unique key, keys to Value (computer science), values. ...
s in
Java Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
, dynamic objects in
JavaScript JavaScript (), often abbreviated as JS, is a programming language and core technology of the World Wide Web, alongside HTML and CSS. Ninety-nine percent of websites use JavaScript on the client side for webpage behavior. Web browsers have ...
. 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: 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 More recent Rexx variants, including Object REXX and ooRexx, provide a construct to iterate over the tails of a stem. do i over stem. say i '-->' 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 * value ''expression'' with 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" parse var myVar firstName lastName say "First name is:" firstName say "Last name is:" lastName displays: 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: Area code is: 202 Subscriber 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. The following example displays 16 and exits. X = 'square' interpret 'say' X , , '(4) ; exit' SQUARE: return arg(1)**2 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 an otherwise 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)*/
Calculation of the value √2: numeric digits 50 n=2; r=1 do forever /* Newton's method */ rr=(n/r+r)/2 if r=rr then leave r=rr end say "SqRt" n "=" r Output: Calculation of the value : numeric digits 50 e=2.5; f=0.5 do n=3 f=f/n ee=e+f if e=ee then leave e=ee end say "e =" e Output:


Error handling

The signal instruction configures the runtime to run custom code to handle a system condition if triggered. Conditions include: * error Positive return code from a system command * failure Negative return code from a system command (e.g. command doesn't exist) * halt Abnormal termination * novalue A variable name was used but the variable is not defined * 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 were lost (ANSI Rexx, not in TRL second edition) The following fragment prints a message when the user terminates (halts) it: signal on halt; do a = 1 say a do 100000 /* a delay */ end end halt: say "The program was stopped by the user" exit Since Rexx version 4, a handler can be named. In the following example, the handler ChangeCodePage.Trap is configured to handle a syntax condition. ChangeCodePage: procedure signal on syntax name ChangeCodePage.Trap return SysQueryProcessCodePage() ChangeCodePage.Trap: return 1004 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.


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 Text editor, screen e ...
*
XEDIT XEDIT is a visual editor for VM (operating system), VM/CMS using block-oriented terminal, block mode IBM 3270 Computer terminal, terminals. (Line-mode terminals are also supported.) XEDIT is much more line-oriented than modern Personal compu ...
* Comparison of computer shells * Comparison of programming languages


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. . * * 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 Association

Rexxinfo.org

The Rexx Language (Background)

REXX programming language
language reference at IBM
Rexx Programmer's Reference 2nd Edition
{{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