next up previous contents
Next: Dynamic Data Exchange Up: More Advanced Features Previous: Cursors

Dynamic Loading

Subroutines in DLL's can also be called from within XLISP-STAT. The subroutine should be defined as for dynamic loading on the Macintosh and should use C, not Pascal, calling conventions. The header file xlsx.h contains the required definitions and macros. The call-cfun function requires two arguments to identify the routine to be loaded, a DLL handle and an ordinal index or a name string. Suppose the file foo.c shown on page 362 of Tierney (1990) is linked with the DLL code xlsx.c using the module definition file foo.def given by

LIBRARY FOO
EXETYPE WINDOWS
CODE    PRELOAD MOVEABLE DISCARDABLE
DATA    PRELOAD MOVEABLE SINGLE
EXPORTS FOO=_foo
        WEP
If the DLL is loaded as
(setf foo-dll (load-dll "foo.dll"))
then the routine foo can be called using either
(call-cfun foo-dll "foo" 5 (float (iseq 1 5)) 0.0)
or
(call-cfun foo-dll 1 5 (float (iseq 1 5)) 0.0)
The second approach works since foo is the first routine in the exports table.



Luke Tierney
Mon Aug 30 09:50:11 CDT 1999