Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.

12.4 Example Module Use

The gadget example program in Part Three shows how to use constants from the module `intuition/intuition' (see 22.1 Gadgets), and the IDCMP example program shows the object gadget from that module being used (see 22.2 IDCMP Messages). The following program uses the modules for the Reqtools library, which is not a standard Amiga system library but a commonly used one, and the appropriate modules are supplied with Amiga E. To run this program, you will, of course, need the `reqtools.library' in `Libs:'.

MODULE 'reqtools'

PROC main()
  DEF col
  IF (reqtoolsbase:=OpenLibrary('reqtools.library',37))<>NIL
    IF (col:=RtPaletteRequestA('Select a colour', 0,0))<>-1
      RtEZRequestA('You picked colour \d',
                   'I did|I can\at remember',0,[col],0)
    WriteF('Could not open reqtools.library, version 37+\n')

The reqtoolsbase variable is the library base variable for the Reqtools library. This is defined in the module `reqtools' and you must store the result of the OpenLibrary call in this variable if you are going to use any of the functions from the Reqtools library. (You can find out which variable to use for other libraries by running the showmodule program on the library module.) The two functions the program uses are RtPaletteRequestA and RtEZRequestA. Without the inclusion of the `reqtools' module and the setting up of the reqtoolsbase variable you would not be able to use these functions. In fact, if you didn't have the MODULE line you wouldn't even be able to compile the program because the compiler wouldn't know where the functions came from and would complain bitterly.

Notice that the Reqtools library is closed before the program terminates (if it had been successfully opened). This is always necessary: if you succeed in opening a library you must close it when you're finished with it.

Go to the Next or Previous section, the Detailed Contents, or the Amiga E Encyclopedia.