Overview

An IMLPlus program can call external user-defined functions written using the C programming language. Because external user-defined functions are always executed on the client Windows PC, a C function must be compiled and linked for use with the Microsoft Windows operating system before it can be called by IMLPlus. Specifically, the C function must be packaged within, and exported from, a Dynamic-Link Library (DLL). To call the C function, an IMLPlus program uses the DllFunction class.

There are three steps to calling a C function from an IMLPlus program:

  1. Package the C function within, and export it from, a DLL.
  2. Write a wrapper module to encapsulate the IMLPlus programming statements necessary to use the DllFunction class to call the C function.
  3. Call the wrapper module from the main program.

To demonstrate each of these steps, the following topics present an example of packaging a C function within a DLL and then calling it from an IMLPlus program:

Packaging a C Function within a DLL

Writing a Wrapper Module to Call the C Function

Calling the Wrapper Module from the Main Program

The example function multiplies a vector by a scalar and returns the product vector. Mathematically, it computes y = c x where x is a vector and c is a scalar.