The REXX reference article from the English Wikipedia on 24-Apr-2004
(provided by Fixed Reference: snapshots of Wikipedia from wikipedia.org)

REXX

Sponsorship the way you would do it
REXX (Restructured Extended Executor) is a programming language which was developed at IBM. It is a modern, structured, high-level programming language which was designed to be both easy to learn and easy to read. Interpreters for REXX are available on a wide range of computing platforms.

Table of contents
1 Features
2 History
3 Syntax
4 Under OS/2
5 Spelling
6 External links

Features

REXX has the following characteristics and features:

REXX has just twenty-three, largely self-evident, keywords (e.g., CALL, PARSE, and SELECT) and minimal punctuation requirements. It is essentially a free-form language with only one data-type, the character string; users never have to worry about data conversion.

REXX looks a lot like PL/1.

History

REXX was designed and implemented 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.

Over the years IBM developed versions of REXX for many of its operating systems: VM/CMS, OS/2, PC-DOS, MVS/TSO, AS/400, and AIX. Non-IBM versions have also been developed for Atari, Unix, DEC, Windows, and MS-DOS. Later versions of the Amiga OS included a version of REXX called ARexx.

Several freeware versions are available. REXX/IMC and Regina are the most widely-used open-source ports to Windows and Linux.

In 1996 ANSI published a standard for REXX: ANSI X3.274-1996 "Information Technology - Programming Language REXX"

In recent years, two newer variants of REXX have appeared:

Syntax

Looping

The DO control structure always begins with a DO and ends with an END.

DO UNTIL:

   do until [condition]
   [instructions]
   end


DO WHILE:

   do while [condition is true]
   [instructions]
   end


Stepping through a variable:

   do i = x to y by z
   [instructions]
   end


Looping forever until exiting with LEAVE: 

   do forever
     if [condition] then leave
   end

Looping a fixed number of times

   do i = x to y by z for a
   [instructions]
   end

Conditionals

Testing conditions with IF

   if [condition] then
     do
     [instructions]
     end
   else
     do
     [instructions]
     end

For single instructions, DO and END can also be omitted:

   if [condition] then
     [instruction]
   else
     [instruction]

Testing for multiple conditions

SELECT is REXX's CASE structure

   select
     when [condition] then
     do
     [instruction]
     end
   otherwise
     do
     [instruction] or NOP
     end

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:

   parse [upper] origin template

where origin specifies the source:

and template can be: upper is optional; it you specify it, data will be converted to upper case.

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.

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. Under OS/2, a REXX program begins with matched comment delineaters, /* */, to indicate to the operating system that it is a REXX program:

   /* sample.cmd */
   say "Hello World"

Instructions between quotes are passed to the OS:

   /* sample.cmd */
   'dir /p /w'

Spelling

Cowlishaw seems to prefer Rexx, whereas IBM sales, ANSI, and the majority of the web uses REXX.

External links


Programming languages
Ada | Algol | APL | BASIC | C | C++ | C# | Cg | COBOL | Common Lisp | ColdFusion | Delphi | Eiffel | Forth | FORTRAN | Haskell | Java | JavaScript | Jython | Lisp | Logo | Mesa | ML | Modula-2 | Oberon | Objective-C | Objective Caml | Pascal | Perl | PHP | PL/I | PostScript | Powerbuilder | Prolog | Python | QBASIC | REXX | Ruby | Scheme | Smalltalk | Tcl/Tk | Visual Basic