Newsgroups: bit.listserv.i-amiga
Date:         Mon, 7 Sep 1992 11:40:50 EDT
From:         Ernest Crvich <GENERAL@VTVM1.BITNET>
Subject:      Re: Beginners Guide To AREXX

On Sun, 6 Sep 1992 21:28:00 EDT <BARNETTJ@SNYSYRV1> said:
>1) To startoff any arexx script, the opening line must include a comment
>/* Comment in here */

   Two points of interest here :
      (1) REXX comments, you'll notice, are the same as in C.  This
          may be one reason C programmers like REXX...  :)
      (2) Note that (of course) comments may extend across many lines :
             /*
              *  comment
              */
          This is common knowledge for C programmers, but I thought it
          worth pointing out that this is the same for REXX.

>The format for say is say ' stuff to be printer '   Note the quotes can
>be single or double

   SAY is very flexible ; you can use constant strings (as in your
example), variables (any kind), concatenation operators, etc. as
arguments.
   REXX is IMHO a very forgiving language...

>Address Command "run dh0:prowrite"

   Note that, in most cases, you can omit the 'address command' text.
When a quoted string is found by itself by the REXX interpreter, it just
passes that string straight to whatever program started the REXX script.
Hence, when you run a REXX script from an AmigaDOS shell, a quoted string
will be passed on to the shell interpreter.  However, using explicit
address commands are IMHO better programming style, and perform a kind
of documentation (that is, the maintenence programmer knows exactly where
a non-REXX command is going to be sent).

>Address 'ProWrite'
>
>That is something different.  Here I am letting arexx know that if
>it comes across any commands it has never seen before, it should check
>the wordprocessor ProWrite, which is running concurrently, to see

   More correctly, the address command opens communication to a 'port'
named ProWrite...'ProWrite' may be the (poorly) named port of a game for
all REXX cares.  The Abacus book on AREXX explains ports in some detail.

>Unfortunately, from my own experimentation and search, the closest to
>this that arexx allows you is the following
>fish.1= ' '; fish.2=' ';fish.3=' ';fish.4=' ';fish.5=' '....and so on
>to 100

   This isn't the case (fortunately!).  I must have missed your original
posting about your REXX array problem.  If you could send me the array
code that doesn't work how you want it, I'll see if I can discover your
problem.

>do I = 1 to 100
>Say 'Enter the data'
>parse pull answer
>fish.i= answer
>end

   This should work, although there is one thing to note : REXX is not
case-sensitive with reference to variable names.  I, however, *have*
experienced strange problems using different case for the same variable
name (as you have in your code snippet above).  It may be that this is
your problem (this could be version/system specific).

>Parse is roughly equivalent to Input from basic
>Pull is just a option for cursor input.

   'PULL' is equivalent to 'PARSE UPPER PULL'.  You can 'PARSE' many
things, not just keyboard input : variables (PARSE VAR), arguments (from
the command line) (PARSE ARG), and expressions (PARSE VALUE).  There may
be others depending on the system you're using REXX on (I'm using the
VM/XA version on the CMS operating system).
   Again, this is kind of related to good programming style : while 'PULL'
works, 'PARSE UPPER PULL' is more informative.  Note : both 'PULL' and
'PARSE UPPER PULL' translate input to uppercase.  To get input 'as-is',
use simply 'PARSE PULL'.

>/*this is my rem statement so that I can run this dumb script */

   Again referring to the software engineering concept, this comment-
enforcing feature should influence programmers to both document their
code more and to put an *informative* header at the beginning of it
(describing its purpose, methodology, etc.).  I've read that the comment-
on-the-first-line convention was developed only to tell some operating
systems what kind of script it was (here on CMS we have at least 3 dif-
ferent scripting languages)...but it's credible that it could be viewed
as a documentation influence.

>Parse pull answer
>if answer <> "A" and answer <> "B" then exit /* end script */

   Note that if the user entered a lowercase 'a', this script would
not work properly.  You should have used 'PARSE UPPER PULL' (or 'PULL')
instead of 'PARSE PULL'.

>if answer = "B" then do

   Note that REXX supports C-style assignment/comparison operators, and
should probably be used (i.e., '=' for assignments and '==' for comparisons)
for clarity. (if answer == 'B' then do)

   Hope I didn't come across as too 'preachy'...but I happen to believe
in the programming style concept to some extent.  I like REXX.  In fact,
I think it's possibly one of the best scripting languages to come down
the pike...very flexible and powerful.  I hope more REXX discussion
appears here in the future (oops, I guess I should say 'AREXX', so that
it will validate using this list for discussion).
   Later,
--
Ernest Crvich                    ''There is absolutely no reason one dog
general@vtvm1.cc.vt.edu            should be able to take a human in
crvich@csugrad.cs.vt.edu           a fight.'' -- overheard on campus
Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU