Using DLL Procedures

At this point, the DLL procedures are defined. Since we made the procedures public, you can call the procedures directly from any of your application modules, procedures, or tests. You need to define the variables nStatus and nHandle as short. Then, you need to call the Gx6138Initialize procedure as shown here with the PXI slot number (5) as displayed in the PXI-PCI Explorer

Gx6138Initialize(5, nHandle, nStatus)

This will be used to initialize the board to retrieve the board handle, later it will be used with all other commands such as Gx6138Close, which closes relay #2 as shown here:

GT20Close(nHandle, 2, nStatus)

Alternatively, you can use the GXSW library to call the procedure:

GXSW.Gx6138Close(nHandle, 2, nStatus)

Or, by using the driver name:

MyRELAY.GXSW.Gx6138Close(nHandle, 2, nStatus)

Or even:

MyRELAY.Gx6138Close(nHandle, 2, nStatus)

Note that the first two examples call the RELAY driver instead of the MyRELAY driver if the RELAY driver is defined as the first driver in the system. To avoid this, the last two methods are preferred.

As you can see, calling a DLL procedure is very similar to calling an ATEasy procedure. Typically, after defining the DLL procedure, you will create Commands to provide the user a better interface than procedures. In addition, use commands to provide a simpler interface to hide the nHandle and pnStatus parameters each of the DLL procedures have. So, instead of calling GT20Close with tree parameters as shown previously, enter the command as:

RELAY Close (2)

This code is a lot simpler; it hides the implementation details from the user. The user does not need to know about nHandle or about error handling and nStatus as explained in Driver Initialization.