Skip to content

riapplib

This library makes a program part of Workbench. An App window is a window on the Workbench screen that files can be dragged into; an App icon is an icon on the Workbench desktop that files can be dropped on or that can be double-clicked; an App menu item is an item in the Tools menu of Workbench. Each of them sends a message to the program when the user uses it, together with the files that were dropped or selected.

The library needs workbench.library, dos.library and icon.library of version 37 or later, so Kickstart 2.04 or later. Without them, as on Kickstart 1.x, a program with the library runs, but the commands do nothing and return 0 or an empty string (AppEventIDCMP excepted). All commands but AppEventIDCMP work in Amiga mode only.

Every App object has an id from 0 to 15, one set of 16 for each kind; for an App window the id is the number of its window. With runtime error checking, an id outside 0 to 15 stops the program with the runtime error “App id must be 0 to 15”, a window number outside it with “App window number must be 0 to 15”; without it, such a number overwrites memory. Adding an object with an id that is in use removes the old one first.

AppEvent fetches the next message; AppEventType, AppEventID, AppNumFiles, NextAppFile and AppFile then tell what happened. The library removes the objects that are left when the program ends, and answers the messages that are still waiting.

An App icon that prints the files dropped on it:

If AddAppIcon(0,"Drop here","SYS:System/Format")=0 Then End
Repeat
  VWait
  If AppEvent
    For n=1 To AppNumFiles
      NPrint NextAppFile
    Next
  EndIf
Until Joyb(0)
DelAppIcon 0

The fixed bugs of the library are listed in Fixes in riapplib.

Based on the RI App Library guide by Reflective Images (Red When Excited).

Library number 61.

Commands

AddAppIcon

Puts an App icon with the label text$ and the id id on the Workbench desktop, with the image of the icon of the file filename$. Returns -1 on success, 0 on failure.

Statement or function, result .l. Help text: (id,text$,filename$[,x,y])
2 forms:

  • .l, $, $
  • .l, $, $, .l, .l

filename$ is the name of the file without .info. With x and y the icon appears at that position, without them Workbench chooses one.

AddAppMenu

Adds an item with the text text$ and the id id to the Tools menu of Workbench. Returns -1 on success, 0 on failure.

Statement or function, result .l. Help text: (id,text$)
Arguments: .l, $

AddAppWindow

Makes the window with the number given an App window, so that files can be dragged into it; the window number is its id. Returns -1 on success, 0 on failure.

Statement or function, result .l. Help text: (windownumber)
Arguments: .l

The window number must be 0 to 15. With runtime error checking, a number outside stops with the runtime error “App window number must be 0 to 15”; without it, such a number overwrites memory.

AppEvent

Answers the message fetched before and fetches the next message of an App window, icon or menu item. Returns $800000 if there is one, else 0.

Function, result .l. No help text.
No arguments.

The message stays the current one, for AppEventType, AppEventID, AppNumFiles, NextAppFile, AppFile, AppLock and AppMessage, until the next AppEvent. At the end of the program, the library answers the current message and the messages that are still waiting.

AppEventID

The id of the object that sent the current message, or -1 if there is no message.

Function, result .l. No help text.
No arguments.

AppEventIDCMP

The value $800000 that AppEvent returns for a message. Works in Blitz mode too.

Function, result .l. No help text.
No arguments.

AppEventType

The kind of object that sent the current message - 1 an App window, 2 an App icon, 3 an App menu item - or 0 if there is no message.

Function, result .l. No help text.
No arguments.

AppFile

The full path of file num of the current message, counted from 1; an empty string if there is no such file. The position of NextAppFile stays.

Function, result $. Help text: (num)
Arguments: .l

AppLock

The lock of the drawer of the file that NextAppFile or AppFile read last from the current message, or of its first file before either has read one. 0 if there is no message or the message has no files, as for an App menu item chosen without icons selected.

Function, result .l. No help text.
No arguments.

AppMessage

The address of the current message (an AppMessage of the operating system), or 0 if there is none.

Function, result .l. No help text.
No arguments.

AppMsgPort

The address of the message port that receives the messages of all App objects of the program, or 0 if the library could not open what it needs when the program started.

Function, result .l. No help text.
No arguments.

AppNumFiles

The number of files, drawers and disks of the current message, or 0 if there is no message.

Function, result .l. No help text.
No arguments.

DelAppIcon

Removes the App icon with the id id from the Workbench desktop. Returns -1, or 0 if there is no such icon.

Statement or function, result .l. Help text: (id)
Arguments: .l

DelAppMenu

Removes the item with the id id from the Tools menu of Workbench. Returns -1, or 0 if there is no such item.

Statement or function, result .l. Help text: (id)
Arguments: .l

DelAppWindow

Makes the App window with the number given a plain window again. Returns -1, or 0 if the window is no App window.

Statement or function, result .l. Help text: (windownumber)
Arguments: .l

NextAppFile

The full path of the next file, drawer or disk of the current message, beginning with the first after each AppEvent; an empty string if there is none left.

Function, result $. No help text.
No arguments.