Copyright (c) Hyperion Entertainment and contributors.

AmigaOS Manual: Python Interprocess communication through ARexx ports

From AmigaOS Documentation Wiki
Revision as of 06:16, 21 January 2019 by Janne Peräaho (talk | contribs) (Added "Interprocess Communication and Ports" and "ARexx Hosts" and moved "Workbench" under the "ARexx Hosts")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Interprocess communication (or IPC for short) refers to a computer's ability to allow the exchange of information between currently running programs.

Interprocess Communication and Ports

Interprocess communication occurs through message ports attached to each program. A message port is an address contained in an application that can receive and send messages. A message send to an application from a Python script will be directed by the Amiga operating system to the application's message port. A message send from an application to a Python script occurs in a like manner.

Each message port has a name (usually the name of the program in capital letters), and sending a message requires the use of the port's name in a Python script. The order of operations in the sending and receiving of a message is briefly described below:

  1. An application opens a message port
  2. The application waits to receive a message
  3. The Amiga lets the application know that a message has arrived
  4. The application acts on the message
  5. The application lets the message's sender know that the message has been received and processed

These five steps are critical in interprocess communication, especially the final step of letting the sender know that the message has been received and processed.

ARexx Hosts

Workbench

Workbench is Amiga's default graphical user interface which opens up when Amiga is booted. Through Workbench you can launch applications and manage files and disks using the mouse. Workbench acts as an ARexx host under the name of WORKBENCH which will allow scripts to command Workbench just as users do.

In order to send commands to Workbench from a Python script, the arexx module must be imported first. The module contains the necessary functions to interface with an ARexx host. The module can be imported as follows:

# Include arexx module
import arexx

After importing the module, commands can be send to Workbench using the dorexx method:

rc1, rc2, result = arexx.dorexx( 'WORKBENCH', 'MENU WINDOW ROOT INVOKE WORKBENCH.ABOUT')

In the example above, Workbench's about requester will be opened by sending a command MENU WINDOW ROOT INVOKE WORKBENCH.ABOUT to Workbench.

Commands

Workbench responds to the commands listed below.

ACTIVATEWINDOW

CHANGEWINDOW

DELETE

FAULT

GETATTR

HELP

ICON

INFO

KEYBOARD

LOCKGUI

MENU

MOVEWINDOW

NEWDRAWER

RENAME

RX

SIZEWINDOW

UNLOCKGUI

UNZOOMWINDOW

VIEW

WINDOW

WINDOWTOBACK

WINDOWTOFRONT

ZOOMWINDOW