REBOL 3 Docs Guide Concepts Functions Datatypes Errors
  TOC < Back Next >   Updated: 26-Jul-2010 Edit History  

REBOL 3 Concepts: Extensions: Using Extensions

The previous section defined extensions as a package that can contain both REBOL and C code and data. This section explains how to import and use extensions.

Importing a extension

Extensions work like modules : you import them before they can be used.

When you import an extension, you load its code and data, which can include both REBOL or C code, as well as any data they might need, such as graphics, images, sounds, tables, or whatever.

To import an extension called example you would write:

import %example.dll

Notice that the file suffix is .dll - a dynamically loaded library. This is how native functions and their data are able to be loaded by your operating system.

The line above will perform these steps to import the extension:

See modules for more detailed information about how some of these steps are processed.

Example usage

Once an extension has been imported, you can use its exported function as you would any other type of function:

import %example.dll  ; exports add-mul

print add-mul 1 2 3

If you want to see the exported definition of the example extension, just type:

probe import %example.dll

This will show you the module header and a list of all its functions and data.

Also, just like modules, you can explicitly reference a command function with an extension:

mysql: import %r3-mysql.dll

sql: mysql/open %books.db
mysql/select sql * 'authors

This is identical to how you reference a field of an object.

  TOC < Back Next > - WIP Wiki Feedback Admin