Measurement Computing ADLIB WIN User Manual
Page 23

Chapter 5 Program Development
5-3
/* Start the logical device. */
errnum& = AL_StartDevice(gblLhld&)
If errnum& < 0 Then
MsgBox "AL_StartDevice Error", MB_ICONSTOP, "ADLIB Error"
Form_Unload (1)
End
End If
' Collect the data and display
errnum& = AL_GetBufferStatus(gblLhld&, lpDataBuffStat, DONE_BUFFER)
If errnum& = 1 Then 'The buffer is avaliable
' Check the status and error flags
If lpDataBuffStat.lStatusFlags <> BUFFER_FULL Then
Msg = "Incomplete Buffer Status = "
Msg = Msg & lpDataBuffStat.lStatusFlags
MsgBox Msg, MB_ICONSTOP, "ADLIB Buffer Status"
Form_Unload (1)
End If
If lpDataBuffStat.lErrorFlags <> 0 Then
Msg = "Buffer Error = "
Msg = Msg & lpDataBuffStat.lStatusFlags
MsgBox "Buffer Error", MB_ICONSTOP, "ADLIB Buffer Error"
Form_Unload (1)
End If
errnum& = AL_CopyBuffer(gblLhld&, lpDataBuffStat.lBuffNum, DataBuff(0), 0, 2048)
If errnum& < 0 Then
MsgBox "AL_CopyBuffer Error", MB_ICONSTOP, "ADLIB Error"
Form_Unload (1)
End If
errnum& = AL_DemuxDataSet(gblLhld&, lpDataBuffStat.lBuffNum, EngUnits(0), 0, 1)
If errnum& < 0 Then
MsgBox "AL_DemuxDataSet Error", MB_ICONSTOP, "ADLIB Error"
Form_Unload (1)
End If
errnum& = AL_ClearBufferDoneFlag(gblLhld&, lpDataBuffStat.lBuffNum)
If errnum& < 0 Then
MsgBox "AL_ClearBufferDoneFlag Error", MB_ICONSTOP, "ADLIB Error"
Form_Unload (1)
End If
lblShowData.Caption = Format$(DataBuff(0), "0") ' print the counts
lblShowVolts.Caption = Format$(EngUnits(0), "0.000") + " Volts" ' print the voltage
ElseIf errnum& < 0 Then 'An error occured in the AL_GetBufferStatus function call
MsgBox "AL_GetBufferStatus Error", MB_ICONSTOP, "ADLIB Error"
Form_Unload (1)
End If
errnum& = AL_StopDevice(gblLhld&)
If errnum& < 0 Then
MsgBox "AL_StopDevice Error", MB_ICONSTOP, "ADLIB Error"
End If