Programming AmigaOS in Basic

Opening a Library

To access shared libraries, you need to open them first before you can use the functions provided. This is done using the LIBRARY command which is an exec.library function.
The exec.library is the only library that is always open and is open as soon as AmigaOS is loaded. To open a library you need to provide the full name of the library or just the name of the library (without the .library bit). Note, in ACE Basic, the dos.library is always open.

Example, Opening the Intuition Library

LIBRARY intuition



LIBRARY "intuition.library"

Using functions in a Library

Before functions can be used, you should declare any functions using the Declare Function statement. Its format is:

DECLARE FUNCTION <name>[%&!#$] [(parameter-list)] LIBRARY [<libname>]

Where name is the name of the function, the symbols determine the return value type, parameter-list is a list of optional values to pass to the function and the libname is an optional library name for Basic to search for the function in that library. The percent (%) is for short integers, ampersand (&) for long integers, exclamation (!) for single-precision numbers, hash(#) for double-precision numbers and dollar sign ($) for strings.
e.g.
DECLARE FUNCTION SetSoftStyle LIBRARY

To invoke a library function, you can use the CALL command with the name of the function and necessary parameters or as part of a expression.
e.g.
CALL SetSoftStyle(param1, param2.. )

 

Closing a Library

To close a library, use the LIBRARY CLOSE statement which closes all opened libraries.

Go to Menu