Copyright (c) Hyperion Entertainment and contributors.

AmigaOS Manual: ARexx Getting Started

From AmigaOS Documentation Wiki
Revision as of 05:10, 23 January 2014 by Steven Solie (talk | contribs) (Created page with "This chapter shows you how to: * Start ARexx * Save Programs * Store Programs * Use sample programs = Starting ARexx = To start using ARexx, you activate the RexxMast progr...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This chapter shows you how to:

  • Start ARexx
  • Save Programs
  • Store Programs
  • Use sample programs

Starting ARexx

To start using ARexx, you activate the RexxMast program. The RexxMast program is started automatically or manually. Each time ARexx is started or stopped, a text message appears.

To Start ARexx Automatically

There are two methods to start ARexx automatically: placing the RexxMast icon in the WBStartup drawer or editing the S:User-Startup file.

To place RexxMast in the WBStartup drawer:

  1. Open the System drawer.
  2. Drag the RexxMast icon over the WBStartup drawer.
  3. Reboot your Amiga.

To edit the S:User-Startup file:

  1. Open a text editor.
  2. Open the S:User-Startup file.
  3. Enter REXXMAST >NIL:
  4. Save the file.
  5. Reboot your Amiga.

To Start ARexx Manually

There are two ways to start RexxMast manually: double-click on the RexxMast icon in Workbench or start it from the Shell. Floppy-based system users can save disk space by starting ARexx only when necessary.

To start RexxMast from Workbench:

  1. Open the System Drawer.
  2. Double-click on the RexxMast icon.

To start RexxMast from the Shell:

  1. Open a Shell.
  2. Type REXXMAST >NIL: and press Enter.

About ARexx Programs

ARexx programs are usually stored in the REXX: directory (which is generally assigned to the SYS:S directory). Although programs can be stored in any directory, storing them in REXX: has several advantages:

  • You can run the program without having to type the complete path.
  • All of your ARexx programs will be in the same place.
  • Most applications search for ARexx programs in REXX:.

Just as you can store an ARexx program anywhere, you can also name it anything you choose. However, adopting a simple naming convention will make program management much easier. Programs run from the Shell should have a .rexx extension to distinguish them from files run from other applications.

Running ARexx Programs

The RX command is used to run an ARexx program. If a complete path is included with the program name, only that directory is searched for the program. If no path is included, the current directory and REXX: are checked.

As long as your programs is stored in the REXX: directory, you do not need to include the .rexx extension when specifying your program name. In other words, typing:

RX Program.rexx

is the same as:

RX Program

A short program can be entered directly at the command line by enclosing the program line in double-quotes. For example, the following program will send five files named myfile.1 through myfile.5 to the printer.

RX "DO i=1 to 5;
ADDRESS command `copy myfile.' | | i `prt:'; END"

When an application is ARexx-compatible, you can run ARexx programs from within the application by choosing a menu item or by specifying command options. Refer to the application's documentation for more information.

ARexx programs can be run from the Workbench by creating a tool or project icon for the program. You must specify the RX command as the Default Tool for the icon. In the icon's Information window, enter:

Default Tool: SYS:Rexxc/RX

When the icon is opened, RX starts RexxMast (if it is not already running). It executes the file associated with the icon as an ARexx program.

ARexx accepts two Tool Types: Console, to specify a window, and CMD, to specify a command string. You enter these Tool Types in the project icon's Information window as:

Console=CON:0/0/640/200/Example/Close
CMD=rexxprogram

Program Examples

The following examples illustrate how to use ARexx to display text strings on your screen, to perform calculations, and to activate the error checking feature.

Programs can be entered into any text editor, such as ED or MEmacs, or a word processor. Save your program as an ASCII file if you use a word processor. ARexx supports the extended ASCII character set (Å, Æ, ß). These extended characters are recognized as ordinary printing characters and will be mapped from lowercase to uppercase.

The examples also illustrate the use of some basic ARexx syntax requirements such as:

  • Comment lines
  • Spacing rules
  • Case-sensitivity
  • Use of single and double quotes

Each ARexx program consists of a comment line that describes the program and an instruction that displays text on the console. ARexx programs must always begin with a comment line. The initial (slash asterisk) /* balanced with an ending (asterisk slash) */ tells the RexxMast interpreter that it has found an ARexx program. Without the /* and the *\, RexxMast will not view the file as an ARexx program. Once it begins executing the program, ARexx ignores any additional comment lines within the file. However, comment lines are extremely useful when reading the program. They can help organize and make sense of a program.