beautypg.com

Including adlib win in visual basic for windows, Steps to programming in visual basic for windows – Measurement Computing ADLIB WIN User Manual

Page 22

background image

Chapter 5 Program Development

5-2

5.2 INCLUDING ADLIB WIN IN VISUAL BASIC FOR WINDOWS

The sections presented below describe the mechanics of incorporating the ADLIB WIN library in a Visual
Basic for Windows based application program. To include the ADLIB library into the Windows
Application Programming Interface(API) add the following basic header files in your program MYPROG
.MAK application.

1. adlib.bas

ADLIB

API

2. adlerr.bas

ADLIB error codes

3. drverr.bas

ADLIB

hardware generic error codes

5.2.1 Steps to Programming in Visual Basic For Windows

Global gblLhld As Long

/* Define a handle variable for the ADC device. */

Global lpDataBuffStat DATABUFFSTATUS

/* Define a pointer to an ADLIB data buffer

structure */

/* Load and initialize the environment. */
errnum&=AL_LoadEnvironment("c:\adlib\alwdm\Pci55mfhr\examples\pci55xx\vbasic\adlai01\adlib.con")
If errnum& < 0 Then
MsgBox "AL_LoadEnvironment Error", MB_ICONSTOP, "ADLIB Error"
Form_Unload (1)
End If

/* Allocate the ADC0 subsystem on board number 0. Reads in the current */
/* initialization file(.INI) and sets the LDSD as defined. */
gblLhld& = AL_AllocateDevice("ADC0", BoardNum&)
If gblLhld& < 0 Then
MsgBox "AL_AllocateDevice Error", MB_ICONSTOP, "ADLIB Error"
Form_Unload (1)
End If

/* Make any changes to the LDSD before initializing the device. All LDSD parameters are either set to
their initialization file (.INI) defaults when specified, otherwise each undefined parameter defaults to the
first or lowest option available in the DAQ board's capability file (.CAP). If the parameter can’t be found in
the capabilities file the option is defined as unsupported. */

errnum& = AL_SetTriggerMode(gblLhld&, "ABOUT_TRIG")
If errnum& < 0 Then
MsgBox "AL_SetTriggerMode Error", MB_ICONSTOP, "ADLIB Error"
Form_Unload (1)
End
End If

errnum& = AL_SetBufferSize(gblLhld&, 256)
If errnum& < 0 Then
MsgBox "AL_SetBufferSize Error", MB_ICONSTOP, "ADLIB Error"
Form_Unload (1)
End
End If

/* Initializes the hardware device to the current LDSD settings. */
errnum& = AL_InitDevice(gblLhld&)
If errnum& < 0 Then
MsgBox "AL_InitDevice Error", MB_ICONSTOP, "ADLIB Error"
Form_Unload (1)
End If