CONTENTS | PREV | NEXT
10B. interfacing to the amiga system with the v40 modules
To use any other library than the five in the previous section, you'll
need to resort to modules. Also, if you wish to use some OBJECT or CONST
definition from the Amiga includes as is usual in C or assembler,
you'll need modules. Modules are binary files which may include constant,
object, library and function (code) definitions. The fact that they're
binary has the advantage over ascii (as in C and assembly), that they
need not be compiled over and over again, each time your program is
compiled. The disadvantage is that they cannot simply be viewed; they
need a utility like ShowModule (see 17A ) to make their contents
visible. The modules that contain the library definitions (i.e the calls)
are in the root of emodules: (the modules dir in the distribution), the
constant/object definitions are in the subdirectories, structured just
like the originals from Commodore.
syntax: MODULE <modulenames>,...
Loads a module. A module is a binary file containing information on libraries,
constants, and sometimes functions. Using modules enables you to use
libraries and functions previously unknown to the compiler.
Now for an example, below is a short version of the source/examples/asldemo.e
source that uses modules to put up a filerequester from the 2.0 Asl.library.
MODULE 'Asl', 'libraries/Asl'
DEF req:PTR TO filerequester
IF RequestFile(req) THEN WriteF('File: "\s" in "\s"\n',req.file,req.drawer)
From the modules 'asl', the compiler takes asl-function definitions like
RequestFile(), and the global variable 'aslbase', which only needs to be
initialised by the programmer (i.e it should not be defined by the
programmer). From 'libraries/Asl', it takes the definition of the
filerequester object, which we use to read the file the user picked. Well,
that wasn't all that hard: did you think it was that easy to program a
filerequester in E?
Note that when objects imported from modules contain references to objects
from yet other modules, with an object member of type PTR TO <object>, this
type will only be set correctly if the object in question is already
available, otherwise it is set to LONG. The only way to influence this is
rearranging the order of modules in the MODULE statement.