REXX
REXX | |
---|---|
![]() |
|
Basic data | |
Publishing year: | 1979 |
Designer: | Michael F. Cowlishaw |
Developer: | Mike Cowlishaw |
Current version : | ANSI X3.274 (1996) |
Typing : | dynamic |
Influenced by: | EXEC 2 |
Operating system : | z / OS , Windows , Linux , AIX , OS / 2 , PC DOS , OS / 400 , AmigaOS , and many more. |
REXX ( R estructured Ex tended E x ecutor ) is a scripting language developed by Mike Cowlishaw at IBM .
origin
REXX comes from the mainframe area . Mike Cowlishaw first implemented it in the 1980s as the successor to the scripting language EXEC 2 under VM (the difference between the relatively simple and not very powerful EXEC-2 and REXX is similar to that between the MS-DOS batch language and BASIC) . REXX stands for "Restructured EXtended eXecutor" (Language). REXX has been ported to TSO and other environments such as OS / 2 . An adapted version - called ARexx - has also enjoyed great popularity on the Amiga since 1987 , as almost every important program can be "remotely controlled" with it. Interpreters are now also available for almost all environments up to the Palm OS . In 1996 REXX became the ANSI standard (ANSI X3.274-1996 "Information Technology - Programming Language REXX").
REXX can be expanded particularly easily by loading dynamic program libraries into the actual interpreter. Under OS / 2 in particular, a variety of such libraries with mathematical, database , socket and system functions is available that can be addressed like normal REXX functions. REXX is usually an interpreted language, but REXX compilers are also available for Linux and for IBM mainframe operating systems.
Basic concepts
Everything is a string
In classic Rexx (in contrast to the object-oriented Rexx not dealt with here but compatible ) every value is a string - including numbers. It is therefore easily possible to change numerical values with string manipulations and immediately use the result as a number again:
a = 2
a = a || '00'
say a / 2
Appending two zeros a
to “multiply” by 100; the result, the character string 200
, can immediately be used again as a number. Is issued 100
.
So working with strings in Rexx is very easy.
The above concatenation operation can also be used as a
a = a'00'
to be written. One or more spaces between a
and '00'
, on the other hand, result in the implicit concatenation inserting a space, which is undesirable if the result is to be a number.
If a number is required because the operator used works with numbers, Rexx tries to interpret the present value as a number:
say ' 1' + 2
outputs 3
.
Normally, Rexx calculates exactly to nine decimal places; however, by specifying a higher number, you can calculate with almost any precision. This Rexx method, which is not close to the hardware, means that arithmetic operations are carried out comparatively slowly.
Evaluation logic
Rexx was developed, among other things, to be able to send commands to an environment in a simple way. This is supported by the following strategy when evaluating an instruction which makes Rexx programs insensitive to newly introduced keywords and which represents a unique selling point of the language:
1. If the second token begins with an equal sign, it is a value assignment
It follows that z. B.
if = 1
is a valid instruction that assigns the value 1 to the variable IF !
On the other hand would be
if == 1
a valid logical expression that checks whether the variable if has exactly the value 1; as an independent statement, however, it results in a syntax error because the value to be assigned = 1 is not a valid expression.
2. If the second token is a colon, it is a token
Brands are needed to implement procedures and functions; these are noted in Rexx after the "executable part" of the program. Example:
say: funk('dir x')
exit
funk: return Arg(1)
One might expect dir x
to see standard output. However, the keyword say
here only acts as a brand; the expression funk('dir x')
already forms the next statement. According to rule 4 (see below) it is funk
called and passed dir x
to the environment for execution. (It would also work without the function funk
; this is just a simple example of a function call.)
It is also possible to go to a specific brand with ; this is rather unusual and only makes sense in certain cases, e.g. B. as an alternative to very large statements.
signal value Ausdruck
select
3. If the first token is a keyword, the evaluation takes place according to this keyword instruction
Such keywords are e.g. B if
. do
,, say
. The late evaluation of the keywords favors extensions. Future versions of the language can thus introduce new keywords without having to revise existing programs: both variables and labels can keep their names.
4. In any other case, the statement is evaluated as an expression and the result is transferred to the environment
This means that the following Rexx instruction (under DOS , Windows , OS / 2 , ...) outputs the content of the current directory:
dir
or:
'dir'
In the first case is dir
a variable; if it was not assigned a value, its value is DIR
(its name in upper case), and it is passed DIR
to the environment and executed. In the second case, it is guaranteed to dir
hand over and execute.
It could be that a future version of Rexx will dir
introduce a keyword . To make sure that the program still works, you can use e.g. B. by
''dir
forced that the instruction is recognized as an expression (concatenation of the variables with the empty string); or you can simply use the variant of passing the command as a string constant.
literature
- Michael Cowlishaw: The Rexx Language: A Practical Approach to Programming. ISBN 0-13-780651-5 .
- Johann Deuring: REXX basics for z / OS practice . 2005. ISBN 978-3-486-20025-6
- Michael Metz et al .: ARexx. An introduction and more. ISBN 3-930733-00-5 .
- Karlheinz Wittemann: REXX under MVS-TSO / E. ISBN 3-446-17956-9 .
- Karlheinz Wittemann: Inside z / OS. The large TSO-REXXikon , 2009, ISBN 978-3-00-029410-5 .
- Howard Fosdick: Rexx Programmer's Reference. Wiley / Wrox, 2005, ISBN 0-7645-7996-7 .
- Merrill Callaway: The ARexx Cookbook. A Tutorial Guide to the ARexx Language on the Commodore Amiga Personal Computer , 1992, ISBN 978-0963277305 .
Web links
- RexxLA Rexx Language Association
- Regina. Open source implementation for Unix and Windows
- Open Object Rexx - Open source project under the care of the Rexx Language Association (RexxLA), which is further developing IBM's Object REXX.
- REXX for Palm OS
- REXX / 400 Programmers Guide (PDF; 854 kB)