Information AboutRexx |
| CATEGORIES ABOUT REXX | |
| ibm software | |
| programming languages | |
| scripting languages | |
| text-oriented programming languages | |
| command shells | |
|
FEATURES REXX has the following characteristics and features:
REXX has just twenty-three, largely self-evident, instructions (''e.g.'', call, '''parse''', and '''select''') with minimal punctuation and formatting requirements. It is essentially an almost 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 REXX was designed and first implemented as an ‘own-time’ project between 20 March 1979 and mid- 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 , Windows CE , PocketPC , MS-DOS , Palm OS , QNX , OS/2 , Linux , BeOS , EPOC32 , AtheOS , OpenVMS , OpenEdition , Macintosh , and Mac OS X . The Amiga version of Rexx, called ARexx was included with AmigaOS 2 onwards and was popular for scripting as well as application control. Many Amiga applications have "ARexx ports" built into them which allows control of the application via a user defined script. Several freeware versions of Rexx are available. In 1992 , the two most widely-used Open-source ports appeared: Ian Collier's REXX/imc for Unix and Anders Christensen's Regina (later adopted by Mark Hessling) for Windows and Linux. BREXX is well-known for WinCE and PocketPC platforms. In 1996 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 . Since the mid- 1990s , two newer variants of REXX have appeared:
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 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 under the Common Public License . On February 22 , 2005 , the first public release of ooRexx (Open Object Rexx) was announced. SYNTAX Looping The DO control structure always begins with a DO and ends with an '''END'''. DO UNTIL: do until {Link without Title} {Link without Title} end DO WHILE: do while is true {Link without Title} end Stepping through a variable: do ''i'' = ''x'' '''to''' ''y'' '''by''' ''z'' {Link without Title} end Looping forever until exiting with LEAVE: do '''forever''' if {Link without Title} then leave end Looping a fixed number of times do ''i'' = ''x'' '''to''' ''y'' '''by''' ''z'' '''for''' a {Link without Title} end Looping a specified number of times do ''x'' {Link without Title} end Conditionals Testing conditions with IF if {Link without Title} then do {Link without Title} end else do {Link without Title} end For single instructions, DO and '''END''' can also be omitted: if {Link without Title} then {Link without Title} else {Link without Title} Testing for multiple conditions SELECT is REXX’s CASE structure select when {Link without Title} then {Link without Title} when {Link without Title} then do {Link without Title} end otherwise {Link without Title} 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 {Link without Title} ''origin template'' where ''origin'' specifies the source:
: (the keyword ''with'' is required to indicate where the expression ends)
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. FLEXIBLE 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: do 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 end Array support REXX does not have explicit variable declarations, and likewise no arrays. However, a ''stem'' structure, similar to an array can be produced easily: 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... The drop stem. instruction unsets all ten variables of the form ''stem.i''. 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 It is possible to have multiple substitutions within a stem variable name. Thus, you could have the following: sub1 = 'July' sub2 = 15 sub3 = 2005 Day.sub1.sub2.sub3 = 'Friday' This has the effect of providing a multi-dimensional array SIGNAL: A NEGATIVE EXAMPLE The REXX 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 in other languages (although it is not strictly equivalent, because it terminates loops and other constructs). This can produce difficult to read code:
signal define; use: say a signal end; define: a = "hello world" signal use; end: exit ERROR AND EXCEPTION TREATMENT IN REXX 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. This example will run until stopped by the user: signal on halt; do a = 1 say a
end end halt: say "The program was stopped by the user" exit Conditions 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. 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.
say "Hello World" Instructions between quotes are passed to the OS:
'dir /p /w' 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. Originally just "Rex" because the author liked how it sounded, the extra "x" was added to avoid collisions with other products' names. BOOKS
EXTERNAL LINKS
Interpreters Classic REXX
Object REXX NetREXX Compilers Newsgroups Tutorials
|
|
|