pipx40_setChannelPattern Example (Visual Basic)
For clarity, this example omits initialising the variables vi, subUnit etc. and does no error-checking.
' Dimension a longword data array (index base zero) to contain the
' number of bits necessary to represent the sub-unit (eg. 2 longwords
' supports sub-units having upto 64 switches)
Dim pattern(1) As Long ' Value specifies the highest allowed index
' pattern(0) bit 0 represents switch #1
' pattern(0) bit 1 represents switch #2
' ... etc.
' pattern(0) bit 31 represents switch #32
' pattern(1) bit 0 represents switch #33
' ... etc.
' Setup array data to turn on switches 3, 33 and output to the card
pattern(0) = &H4 ' set longword 0 bit 2 (switch 3)
pattern(1) = &H1 ' set longword 1 bit 0 (switch 33)
Status = pipx40_setChannelPattern(vi, subUnit, pattern(0))
' Add switch 4 to the array and output to the card
pattern(0) = (pattern(0) Or &H8) ' set longword 0 bit 3 (switch 4)
Status = pipx40_setChannelPattern(vi, subUnit, pattern(0))
' ... now have switches 3, 4, 33 energised
' Delete switch 33 from the array and output to the card
pattern(1) = (pattern(1) And &HFFFFFFFE) ' clear longword 1 bit 0 (switch 33)
Status = pipx40_setChannelPattern(vi, subUnit, pattern(0))
' ... leaving switches 3 and 4 energised