User`s guide
Universal Library User's Guide Universal Library for .NET Description & Use
27
If you are programming inside of Visual Studio .NET, the types that are available for a particular enumerated
value display automatically when you type code:
Error handling
For .NET applications, the return value for the Universal Library functions is an object (ErrorInfo), rather than
a single integer value. The ErrorInfo object contains both the numeric value for the error that occurred, as well
as the associated error message. Within a .NET application, error checking may be performed as follows:
ULStat=Board0.AIn(Channel, Range, DataValue)
'check the numeric value of ULStat
If Not ULStat.Value = ErrorInfo.ErrorCode.NoErrors Then
'if there was an error, then display the error message
MsgBox ULStat.Message
EndIf
Service methods
You can access other Universal Library functions that are not board-specific through the MccService class.
This class contains a set of static methods you can access directly, without having to instantiate an
MccService object. The following examples demonstrate library calls to .NET memory management methods:
WindowHandle = MccService.WinBuffAlloc(1000)
MccService.WinBuffFree(WindowHandle)
Configuration methods
In 32-bit Windows applications, you access board configuration information by calling the cbGetConfig and
cbSetConfig API functions. In .NET applications, you access board configuration information through
separate classes, such as cBoardConfig, cCtrConfig, cDioConfig, and cExpansionConfig. Each
configuration item has a separate get and set method.
Some examples of how to access board configuration within a .NET application are shown below:
UlStat = Board0.BoardConfig.GetRange(RangeValue)
UlStat = Board1.DioConfig.GetNumBits(DevNumber, Number)
UlStat = Board2.CtrConfig.GetCtrType(DevNumber, CounterType)
UlStat = Board3.BoardConfig.SetClock(ClockSource)
UlStat = Board4.ExpansionConfig.SetCJCChan(DevNumber, CjcChan)