|AREXX Programming Tutorial Part 1



                           By CROW of The LOC

NOTE : Please Note That All Examples Are Also Included So Than Can Be
Executed Straight Away.

                            What Is ARexx ?

ARexx  (pronounced  A  REX)  is  a  programming language that anyone can
learn!  ARexx lets you write simple "scripts" (programs) that can define
a  task  for  the  computer  to  perform.   A script is just a text file
containing  a  list  of instructions that ARexx understands.  Because of
way  ARexx  can communicate with other programs running at the same time
(thankyou  multi-tasking), you can use MACROS written in ARexx that will
work with specific software applications.

You  can  also use ARexx programs to link operations of several programs
to perform tasks that no one program can accomplish by itself.

                           Origins of ARexx ?

ARexx  is  so named because it is an implementation of the REXX language
on  the Amiga.  REXX is a language definition developed over a number of
years  by Mike Cowlishaw at IBM.  Cowlinshaw began in 1979 with the idea
to  create  a  language that was easy to program in and was designed for
people,  not machines.  The language evolved as the newest versions were
distributed  over  IBM's  massive  VNET  network consisting of over 1000
mainframe  installations.   VNET  users  tested  and  used  the  lastest
versions  of  the language sending suggestions and comments to Cowlishaw
by  electronic  mail.  The amount of testing and refinement that went on
was  staggering.   On  the  system level the language was designed to be
system  independent,  working on a variety of platforms and to be easily
adaptable  to  future  expansion.  It was also designed with support for
communicating  with external "host environments", so that ARexx could be
used  as  a  standard  macro language for operating systems, editors and
other  applications.  In 1985 a version of ARexx was released for MS-DOS
personnel  computers.   In  1987,  REXX  became  the standard Procedures
Language  for  all  IBM systems Application Architecture (SAA) operating
systems,  which  covers  a  large  number  of  systems.   William  Hawes
developed  REXX  for  the  Amiga as ARexx (Amiga REXX), Arexx built up a
loyal  following  mainly  in America, Commodore decided to include ARexx
starting  with  version  2.0  of  the Amigas operating system.  Now most
major  applications  support  ARexx  in some form; even though there has
been  hardly  any  large  advertising  of  ARexx  ot  hype.  But ARexx's
popularity  is  attributed to the fact that most software developers had
access too it and used and supported it in the products.

                              Using ARexx

Before  you can run any ARexx scripts, the ARexx server must be actived,
to  do this run the program RexxMast, once this is running you are ready
to  run ARexx scripts (programs).  When you run the RexxMast program the
following text should be displayed (or something very similar) :-

     ARexx Version 1.15
     Copyright (C) 1987 William S. Hawes
     All Rights Reserved

If  the  above text is not displayed then you have done something wrong,
such as RexxMast is not on the disk you thought it was or you are not in
the  Shell/CLI  you  have  not switched your Amiga on or you are playing
Impossible  Mission  2025 (try the following password "EMPTYI " for last
level !!!) smart game.

If run RexxMast a second time you get the following extra line :-

     REXX server already active

If  you  look  on  your  Workbench Disk you will find a directory called
rexxc  (rexx  commands)  in  this  directory you will find the following
programs.

      RXC         - This removes ARexx server from memory.
      RX          - Run a script or a given ARexx command.
      HI          - Halts all executing ARexx scripts.
      TS          - Starts interactive tracing.
      TE          - Stops interactive tracing.
      TCO         - Opens global tracing console.
      TCC         - Closes global tracing console.
      RXSET       - Set value for and ARexx clip.
      WaitForPort - Wait/Check for port message.
      RXLIB       - Add a name to the Library List.

The  libraries  that are required to use ARexx are :- rexxsyslib.library
and  rexxsupport.library,  both  of  these libraries must be in the LIBS
directory on your boot disk.

The ARexx language is not case dependent like C is, so the following are
all valid and treated the same :-

      say "hello"
      Say "hello"
      SAY "hello"

Blank  lines  are  treated as null statements; they are ignored.  if you
have  learnt  to program with some high level language such as Pascal or
C,  then  you  will find that ARexx is very easy to pickup.  You have an
advantage  but  to  learn  ARexx it is not really that important to know
another  language.   A  bit of an aside, I know the following high level
languages  Pascal,  C,  Pascal plus, Prolog, COBOL, Pascal with Objects,
Visual  Basic  for  Windows  and  also the following low level languages
680x0,  6502, 6510 (Big Head - Stone).  Comments are started with /* and
finish with */ so the three words and finish with, are a comment and are
ignored by ARexx.


/* Hello world in ARexx */

Say "Hello, World!"


ARexx Operators

 ~       = Logical NOT
 +       = Prefix conversion
 -       = Prefix negation
 **      = Exponentiation
 *       = Multiplication
 /       = Division
 %       = Integer division
 +       = Addition
 -       = Subtraction
 ||      = Concatenation
 ==      = Exact Equality
 ~==     = Exact inequality
 =       = Equality
 ~=      = Inequality
 >       = Greater then
 >=,~<   = Greater than or equal
 <       = Less than
 <=,~>   = Less than or equal
 &       = Logical AND
 |       = Logical inclusive OR
 ^,&&    = Logical exclusive OR


Simple output and input ARexx scripts, example 1 to example 4.

/* Example 1 */

Say "What Is Your Name : "
Parse Pull name
Say "Hello, " name


/* Example 2 */

a = 10
b = 20
Say "10 + 20 = " a + b


/* Example 3 */

a = 20
b = 30
c = a + b
Say "20 + 30 = " c


/* Example 4 */

Say "Enter Number 1 : "
Parse Pull a
Say "Enter Number 2 : "
Parse Pull b
c = a + b
Say "Number 1 : " a "  + Number 2 : " b " = " c


Compound statements (If's and Loops)

/* Example 5 */

Do 10
   Say "Hello"
End

Output : Hello
         Hello
         Etc..


/* Example 6 */

a = 10
Do a
   Say "Line : " a   /* Each Line = " Line = 10 "
End

Output : Line : 10
         Line : 10
         Etc...


/* Example 7 */

a = 10
b = 1
Do a
   Say "Line : "b
   b = b + 1
End

Output : Line : 1
         Line : 2
         Etc...


/* Example 8 */

Say "Enter Age : "
Parse Pull num

If num > 21 Then
   Say "Hello, Crusty"
Else
   Say "Hello, Child"


/* Example 9 */

Say "Enter Name : "
Parse Pull name

If upper(name) = 'CROW' Then
   Say "Yeahhhh, Hello Matey !!!"
Else
   Say "Ohhh, Hello " name


/* Example 10 */

Say "Enter Group Name : "
Parse Pull gname

gname = upper(gname)  /* Up Case All Characters */

Select
   When gname = "LSD " Then Say "Grapevine is the Best."
   When gname = "THE LOC" Then Do
                               Say "Erotic Stories 5 ECS"
                               Say "and AGA Versions Out Now !!"
                               End
   When gname = "SCOOPEX " Then Say "Bag Of Shite Of A Group !!!"
   Otherwise Say "Which Group Is That Sorry ???"
End


I  hope  the above examples with aid you in learning ARexx, the best way
to  learn  a  language is to play with it and build up your knowledge of
what  different functions and procedure do.  You will find examples 1 to
10 as ready to run programs on one of the Grapevine disks.  Extracts for
the  article are taken from the book - Using ARexx On The Amiga which is
published  by Abacus, I would recommend this book to anyone who wants to
delve into using ARexx as it is one hell of a useful language.

end.
