ARexx
From Wikipedia, the free encyclopedia
ARexx is an implementation of the IBM REXX language for the Amiga, written in 1987 by William S. Hawes. The implementation has additional Amiga-specific features.
ARexx is an interpreted language. Programs written for ARexx are called "scripts", or "macros"; several programs offer the ability to run ARexx scripts in their main interface as macros.
The main advantage of ARexx is that it can easily communicate with any third-party software that implements an "ARexx port". Any Amiga application can define a set of commands and functions for ARexx to address, thus making the capabilities of the software available to the scripting language.
ARexx can address several applications in the same script, thus offers the opportunity to mix and match functions from the different programs. For example, an ARexx script could extract data from a database, insert the data into a spreadsheet to perform calculations on it, then insert tables and charts based on the results into a word processor document.
Contents |
[edit] History
ARexx was first created in 1987, developed for the Amiga by William S. Hawes. It is based on the REXX language described by Mike Cowlishaw in the book "The REXX Language: A Practical Approach to Programming", published by Prentice Hall in 1985. ARexx was included by Commodore into AmigaOS 2.0 in 1990. This later version of ARexx follows the official REXX language closely; Hawes was later involved in drafting the ANSI standard for REXX.
Development of ARexx has stopped because ARexx is written in 68000 Assembly and must be rewritten in order to function properly with new PPC CPUs1. Also William Hawes is no longer involved in development of Amiga programs because of quarrels in the past with Commodore, Inc. about the licensing of ARexx. Further, there is no Amiga-related firm interested in financing new versions of ARexx. Notwithstanding this fact the existing version of ARexx performs flawlessly and has no major bugs, so no one has yet upgraded it.
More recently Amiga programmers and users have had good experiences with Python programming language. Python is increasingly catching the interest of the Amiga community and is one of the major candidates in succeeding ARexx as integrated language for scripting and expanding the functions of the AmigaOS environment.
[edit] Characteristics
ARexx is a programming language that can communicate with other applications. Using ARexx, for example, one could request data from a database application and send it to a spreadsheet application. To support this facility, an application must be "ARexx compatible" by being able to receive commands from ARexx and execute them. A database program might have commands to search for, retrieve, and save data. MicroFiche Filer is an example of a database program with an extensive ARexx command set. A text editor might have ARexx commands corresponding to its editing command set. For example, The Textra editor supplied with JForth has an extensive ARexx command set, which can be used with JForth to provide an 'integrated programming environment'. AmigaVision, the multimedia presentation program, also has ARexx port built in and can control other programs using ARexx.
ARexx can increase the power of a computer by combining the capabilities of various programs. Because of the wide acceptance of ARexx, Commodore includes it with Version 2.0 of AmigaDOS. If you are an Amiga programmer who is developing an application, it is highly recommended that you provide ARexx compatibility, if appropriate, by inserting an ARexx port in your program.
ARexx uses "typeless" data representation. Other programming languages made distinctions between integers, floating point numbers, strings, characters, vectors, et cetera. In contrast, ARexx deals with all data as strings of characters, making it simpler to write expressions and algorithms. It is not necessary to declare a variable before using it. This feature is typical in a large number of interpreted languages, i.e., the languages in which dynamic data (data that exist during program execution) is handled directly by the interpreter.
Being an interpreted language ARexx has no necessity of any complicated compiler, linker, debugger or development environment. It has a very simple internal mechanism of execution "step by step" of its programs, so anyone could control how execution is performed and correct errors right on the fly. This feature is very useful to increase speed of development of any program and is invaluable for any non experienced user.
All ARexx scripts have to deal with a very complete and sophisticated error handling system which is monitoring any error that could occur during execution. The user could choose in any situation to suspend and resume the execution of the program.
ARexx interpreter gives to the user a simple but powerful system to handle resources. It frees the memory allocated for the variables when an ARexx program ends its execution, it closes open files and the libraries that the program used, et cetera.
ARexx is an imperative language, i.e., it is based on the execution of instructions in a sequence. It is oriented to structured, procedural, and modular programming. The ARexx command set is poor, but in addition to the commands there are the functions of its Amiga reference library (rexxsyslib.library). It is also very simple to add other libraries to ARexx base library or add any new function that could help the programmer. ARexx scripts can also be invoked as functions from other ARexx scripts.
Any Amiga program which has an ARexx port built in can be used by ARexx to pick any function, procedure, or feature and share it with ARexx scripts. This means that ARexx deals with any program which has an ARexx port built into as an entire new set of available commands.
Finally, ARexx has been built to integrate with the Amiga OS system in order to deal at its best with Amiga preemptive multitasking capabilities.
[edit] Examples of ARexx solutions to common problems
Example 1: Lack of features in a program and repetitive procedures
If end user is using a program which build animations joining various bitmap image files but has not image processing capabilities, then he could write an ARexx script which performs these actions:
ARexx locates files in their directory/directories -> ARexx loads first image -> it loads paint program -> image is loaded into paint program which performs modifications to file -> modified image is stored into another directory -> ARexx repeats procedure on any image in the directory -> paint program is closed and animation program is loaded -> animation is built -> animation is saved in its directory -> animation program is closed -> user could be prompted that job is finished -> end of ARexx script
Example 2: Avoiding repetitive procedures
EqFiles.rexx V2.2 is a common example of a simple ARexx script written by an experienced Amiga user2 who wants to automate repetitive and boring procedures and has enough skills and knowledge of AmigaOS to write such an ARexx program. This REXX script uses another program present in aminet repository ALeXcompare3 which compares files. EqFiles finds all duplicates in any set of files and returns output by highlighting any results in a different color.
Example 3: Expand AmigaOS capabilities
One of the main features of ARexx is the fact it could expand the capabilities of an OS (AmigaOS) by adding some procedures the OS lacked. For example a simple ARexx program could be written to print a warning message on the screen of the monitor, or play an audio alert signal if a certain Amiga program stops, faults or has finished its scheduled job.
Here follows an example of the structure of a very minimal ARexx script (not correct or debugged and with no arguments and no calls to AmigaDOS) which should print on the monitor screen some alarm warnings depending on an event that could take place or not.
Alarm.rexx
/* Alarm.rexx */
ARG event
IF event = 0 THEN EXIT
IF event = 1 THEN SAY "Program has ended unexpectedly"
IF event = 2 THEN SAY "Program has finished its job"
IF event = 3 THEN SAY "Cannot find data in selected directory"
Example 4: Parse data
ARexx can very powerfully be used to parse data and transfer data between a program and another. Because of its internal "typeless" data representation ARexx could be used (for example) to retrieve data from a database file, read any record, avoid internal marks and special characters and send only valid data to a spreadsheet application putting any single invoice of the database in a single cell.
[edit] Notes
Note 1: ARexx is also included in MorphOS Operating System. The Morphos version of ARexx has been completely rewritten for PPC family of CPUs.
Note 2: The author of this script is Professor Fulvio Peruggi who wrote this ARexx script to share his knowledge with the whole Amiga community, so he published it on Aminet internet Amiga repository. He is a well known experienced user in both the Amiga and MorphOS communities. He is also author of various articles regarding Amiga and MorphOS.
Note 3: ALeXcompare was written by the programmer Alex Kazik
[edit] External links
AmigaOS (category) | |
---|---|
Companies: | Commodore International | Hyperion Entertainment |
Computers: | Amiga |
Technology: | Workbench | Intuition | AmigaDOS | ARexx | AmigaBASIC | Amigaguide | Software | Games | Demos |
Operating systems: | AmigaOS (versions) | AROS | MorphOS |