'***********************************************************************
'*Function-
*
'* VBWaitForTable *
'*Description-
*
'* Example assumes one will be sending that there will be 4 strings
*
'* to test for. It may be modified for different sizes or made more
*
'* general. It is provided as an example only. It was used under VB5*
'* Make sure to modify the declaration for WaitForTable as follows
*
'*
*
'* Declare Function WaitForTable& Lib "cdrvhf32.dll"
*
'* (ByVal Port&, ByVal tmout&, ByVal outstr$, instr&)
*
'***********************************************************************
Function VBWaitForTable&(Port&,wait&, nCnt%, out$, Str1$, Str2$, Str3$, str4$)
Dim nI%, lRes&
Dim lAddr() As Long
Dim s1st As String
Dim s2nd As String
Dim s3rd As String
Dim s4th As String
Dim b1st() As Byte
Dim b2nd() As Byte
Dim b3rd() As Byte
Dim b4th() As Byte
If nCnt = 0 Then
Exit Function
End If
'Size to string count + 1
ReDim lAddr(0 To nCnt) As Long
'Set Answer Strings.
'This is probably not needed now that VB strings
'passed to a dll are all null terminated
s1st = Str1$ & Chr(0)
s2nd = Str2$ & Chr(0)
s3rd = Str3$ & Chr(0)
s4th = str4$ & Chr(0)
'Convert strings to byte array and get byte addresses
For nI% = 0 To nCnt% - 1
Select Case nI
Case 0
b1st = StrConv(s1st, vbFromUnicode)
lAddr(nI) = VarPtr(b1st(0))
Case 1
b2nd = StrConv(s2nd, vbFromUnicode)
lAddr(nI) = VarPtr(b2nd(0))
Case 2
b3rd = StrConv(s3rd, vbFromUnicode)
lAddr(nI) = VarPtr(b3rd(0))
Case 3
b4th = StrConv(s4th, vbFromUnicode)
lAddr(nI) = VarPtr(b4th(0))
End Select
Next nI
'Send and wait
VBWaitForTable = WaitForTable&(Port&, wait&, out$, lAddr(0))
End Function
'***********************************************************************
|