From: WILLS@LSTC2VM.stortek.com (Cheyenne Wills)
Newsgroups: comp.os.os2.advocacy
Subject: Re: What REXX does
Date: 3 Sep 92 21:48:44 GMT
Organization: StorageTek SW Engineering

In article <1992Sep3.191634.16945@njitgw.njit.edu>
dic5340@hertz.njit.edu (David Charlap) writes:
 
>
>In article <Bu07yD.Hw7@rice.edu> amitp@owlnet.rice.edu writes:
>>Can someone tell me what REXX does?  I tried reading the online command
>>list and it looks like it has loops/input commands like 4-DOS's batch
>>command extensions, but I couldn't figure out what REXX is used for.
>
>Procedures Language/2 (aka REXX) is an interpreted language that is
>suitable for writing small to medium size applications.  It has some
>hooks into PM and WPS, and can access all CMD.EXE functions.  Its code
>is generally executed via the CMD.EXE command shell, and REXX programs
>have a .CMD extension.  A c-style comment on the first line of a REXX
>program indicates that the file is not a "batch file", which is much
>simpler.
>
>It can be used simply as an enhanced batch language, or applications
>may be written in it.
>--
>   |)  David Charlap           "TELEPHONE, n.  An Invention of the devil which
>  /|_  dic5340@hertz.njit.edu   abrogates some of the advantages of making a
> ((|,)                          disagreeable person keep his distance."
>  ~|~                              --- Ambrose Bierce, The Devil's Dictionary
 
 
It actually is alittle more then just an enhanced batch language, you
can use it as a macro language for apps that have been written to
"register" themselfs as using the macro interface.
 
A prime example is editor macros.  KEDIT from Mansfield and EPM
(included with OS/2) both use Rexx as a macro language (I use KEDIT
and only know that EPM supports Rexx, plus there are probably other
editors out there that also use Rexx).
 
Anyway... a simple KEDIT macro to count the number of nonblank lines
is a file that is being edited follows:
 
----[blankcnt.kex]-----------
/* Count blank lines */
nonblank = 0
blank = 0
'Top'
'Next'
Do While rc = 0
    'Extract/curline/'
    If Space( curline.3 ) <> '' Then nonblank = nonblank + 1
    Else blank = blank + 1
    'Next'
End
'Top'
'Msg There are' nonblank 'nonblank lines and' blank 'blank lines in the file'
-----------------------------
 
The statements in quotes (Top, Next, Extract and Msg) are all
KEDIT commands that are accessed via the macro interface.  When KEDIT
sees the command "blankcnt" on its command line it will search
its own list of internal commands and upon not finding it will search
for a file named "blankcnt.kex".  It will invoke the Rexx interpreter
pointing to the "blankcnt.kex" file.  In addition to passing the
name of the Rexx program, KEDIT will inform the interpreter that the
default command environment is KEDIT's.  What this means is that
any statement that Rexx doesn't recognize as a valid Rexx statement
will be passed to that command environment (a .CMD file the default
command environement is CMD.EXE's).
 
The variable curline.3 is set by the EXTRACT command (there are
ways of a program to set and retrieve Rexx variables).  In this case
curline.3 contains the contents of the current line.
 
+---------------------------------------+-------------------------------+
| +-----+                               | Cheyenne Wills                |
| |     |       "From here on up it is  | Storage Technology Corporation|
| |  +--+--+      downhill all the way" | 2270 South 88th St.           |
| |  |  |  |  +-------------------------+ Louisville, Co. 80028-4232    |
| +--+--+  |  |StorageTek doesn't speak |                               |
|    |     |  |for me and I don't speak | wills@lstc2vm.stortek.com     |
|    +-----+  |for StorageTek.          | cheyenne@stortek.stortek.com  |
+-------------+-------------------------+-------------------------------+