REXX
REXX (Restructured Extended Executor) is a
programming language which was developed at
IBM. It is a structured high-level programming language which was designed to be both easy to learn and easy to read. Both commercial and open source
Interpreters for REXX are available on a wide range of computing platforms, and compilers are available for IBM mainframes.
Features
\nREXX has the following characteristics and features:
- character string basis\n* dynamic data typing (no declarations)\n* no reserved keywords (except in local context)\n* arbitrary numerical precision\n* decimal arithmetic (floating-point)\n* a rich selection of built-in functions (especially string and word processing)\n* automatic storage management\n* crash protection\n* content-addressable data structures\n* straightforward access to system commands and facilities\n* simple error-handling, and built-in tracing and debugger\n* few artificial limitations\n* simplified I/O facilities.
REXX has just twenty-three, largely self-evident, instructions (e.g., call, parse, and select) with minimal punctuation and formatting requirements. It is essentially a free-form language with only one data-type, the character string; this philosophy means that all data are visible (symbolic) and debugging and tracing are simplified.
REXX syntax looks similar to PL/I, but has fewer notations; this makes it harder to parse (by program) but easier to use.
History
\nREXX was designed and first implemented as an ‘own-time’ project between 1979 and 1982 by Mike Cowlishaw of IBM, originally as a scripting programming language to replace the languages EXEC and EXEC 2. It was designed to be a macro or scripting language for any system. As such, REXX is considered a precursor to Tcl and Python.
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, 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/GCS, MVS TSO/E, AS/400, OS/2, VSE/ESA, AIX, CICS/ESA, and PC-DOS), and has made versions available for Novell Netware, Windows, Java, and Linux.
The first non-IBM version was written for PC-DOS by Charles Daney in 1984/5. Other versions have also been developed for Atari, Amiga, Unix (many variants), Solaris, DEC, Windows, WinCE, PocketPC, MS-DOS, Palm OS, QNX, OS/2, Linux, BeOS, EPOC32, AtheOS, OpenVMS, OpenEdition, Macintosh, and MacOS X.\n
Several freeware versions are available. REXX/imc and Regina are the most widely-used open-source ports to Windows and Linux. BREXX is well-known for WinCE and PocketPC platforms.
In 1996 ANSI published a standard for REXX:\nANSI X3.274-1996 “Information Technology – Programming Language REXX”. More than two dozen books on REXX have been published since 1985.
In the last decade, two newer variants of REXX have appeared:
- NetRexx - which compiles to Java byte-code via Java source code; this has no reserved keywords at all, and uses the Java object model, and is therefore not upwards-compatible with ‘classic’ REXX\n*ObjectRexx - which is an object-oriented upwards-compatible version of REXX.
In 1990, Cathy Dager of SLAC organized the first independent REXX symposium, which led to the forming of the REXX Language Association. Symposiums are held annually.
Rexx marked its 25
th anniversary on
20 March 2004, which was celebrated at the REXX Language Association]’s 15
th International REXX Symposium in Böblingen, Germany, in May 2004.
Syntax
Looping
The DO control structure always begins with a DO and ends with an END.
DO UNTIL:\n\n do until [condition]\n [instructions]\n end\n
\nDO WHILE:\n\n do while [condition is true]\n [instructions]\n end\n
\nStepping through a variable:
\n do i = x to y by z\n [instructions]\n end\n
\nLooping forever until exiting with LEAVE:
\n do forever\n if [condition] then leave\n end\n
Looping a fixed number of times
\n do i = x to y by z for a\n [instructions]\n end\n
Conditionals
Testing conditions with IF
\n if [condition] then\n do\n [instructions]\n end\n else\n do\n [instructions]\n end\n
For single instructions, DO and END can also be omitted:
\n if [condition] then\n [instruction]\n else\n [instruction]\n
Testing for multiple conditions
SELECT is REXX’s CASE structure\n\n select\n when [condition] then\n do\n [instruction]\n end\n otherwise\n do\n [instruction] or NOP\n end\n
NOP indicates no instruction is to be executed.
PARSE
The PARSE instruction is particularly powerful; it combines some useful string-handling functions. Its syntax is:
\n parse [upper] origin template\n
where origin specifies the source:\n* arg (command line variable)\n* linein (keyboard)\n* pull (REXX data queue)\n* source (OS/2 info on how program was executed)\n* value (a literal or a function)\n** the keyword with required to indicate where the literal ends\n* var (a variable)\n* version (version/release number)
and template can be:\n*list of variables\n*column number delimiters\n*literal delimiters
upper is optional; it you specify it, data will be converted to upper case.
Examples:
Using a list of variables as template
\n myVar = "John Smith"\n parse var MyVar firstName lastName\n say "First name is:" firstName\n say "Last name is:" lastName\n
displays the following
\n First name is: John\n Last name is: Smith\n
Using a delimiter as template:
\n myVar = "Smith, John"\n parse var MyVar LastName "," FirstName\n say "First name is:" firstName\n say "Last name is:" lastName\n
also displays the following
\n First name is: John\n Last name is: Smith\n
Using column number delimiters:
\n myVar = "(202) 123-1234"\n parse var MyVar 2 AreaCode 5 7 SubNumber\n say "Area code is:" AreaCode\n say "Subscriber number is:" SubNumber\n
displays the following
\n Area code is: 202\n Subscriber number is: 123-1234\n
A template can use a combination of variables, literal delimiters, and column number delimiters.
Under OS/2
REXX is included in the base operating system of OS/2, and is also used as the macro language in many applications.\nUnder OS/2, a REXX program begins with matched comment delimiters, /* */, to indicate to the operating system that it is a REXX program:
\n /* sample.cmd */\n say "Hello World"\n
Instructions between quotes are passed to the OS:
\n /* sample.cmd */\n 'dir /p /w'\n
Spelling
In plain text, Cowlishaw seems to prefer Rexx, whereas IBM documents and the majority of the web uses REXX. The ANSI standard uses the form preferred by the standardization committee, which has small capitals for the final three letters: REXX.
External links
Category:Programming languages