home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 August / Chip_1999-08_cd.bin / sharewar / wscmclib / WSCCLASS.CLS < prev    next >
Text File  |  1999-06-01  |  5KB  |  163 lines

  1. '
  2. ' WSC Visual Basic Class  (wscClass.cls)
  3. '
  4. ' Requires Visual Basic 5.0 or higher. See ATOK project for an example.
  5. '
  6. ' This class is a wrapper for calls to the serial I/O (SIO) functions
  7. ' defined in WSC32.BAS, which makes calls to the functions in WSC32.DLL.
  8. '
  9. ' The arguments are identical to those in WSC32.BAS, except that string
  10. ' results are returned using the ResultString property. The size of the
  11. ' maximum result string is set by the 'WorkSize' constant, but can be 
  12. ' modified as necessary.
  13. '
  14.  
  15. VERSION 1.0 CLASS
  16. BEGIN
  17.   MultiUse = -1  'True
  18. END
  19. Attribute VB_Name = "wscClass"
  20. Attribute VB_GlobalNameSpace = False
  21. Attribute VB_Creatable = False
  22. Attribute VB_PredeclaredId = False
  23. Attribute VB_Exposed = False
  24. Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
  25. Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
  26. 'local variable(s) to hold property value(s)
  27.  
  28. Const WorkSize = 5000
  29. Private WorkBuffer As String * WorkSize
  30. Private WorkLength As Long
  31.  
  32. Public Function fBaud(ByVal Port As Long, ByVal BaudCode As Long) As Long
  33. fBaud = SioBaud(Port, BaudCode)
  34. End Function
  35.  
  36. Public Function fBrkSig(ByVal Port As Long, ByVal Cmd As Long) As Long
  37. fBrkSig = SioBrkSig(Port, Cmd)
  38. End Function
  39.  
  40. Public Function fCTS(ByVal Port As Long) As Long
  41. fCTS = SioCTS(Port)
  42. End Function
  43.  
  44. Public Function fDCD(ByVal Port As Long) As Long
  45. fDCD = SioDCD(Port)
  46. End Function
  47.  
  48. Public Function fDone(ByVal Port As Long) As Long
  49. fDone = SioDone(Port)
  50. End Function
  51.  
  52. Public Function fDSR(ByVal Port As Long) As Long
  53. fDSR = SioDSR(Port)
  54. End Function
  55.  
  56. Public Function fDTR(ByVal Port As Long, ByVal Char As Long) As Long
  57. fDTR = SioDTR(Port, Char)
  58. End Function
  59.  
  60. Public Function fEvent(ByVal Port As Long, ByVal Mask As Long)
  61. fEvent = SioEvent(Port, Mask)
  62. End Function
  63.  
  64. Public Function fFlow(ByVal Port As Long, ByVal Code As Long) As Long
  65. fFlow = SioFlow(Port, Code)
  66. End Function
  67.  
  68. Public Function fGetc(ByVal Port As Long) As Long
  69. fGetc = SioGetc(Port)
  70. End Function
  71.  
  72. Public Function fGets(ByVal Port As Long, ByVal BufLen As Long) As Long
  73. Dim Code As Long
  74. ' Get string result from "ResultString" property
  75. If BufLen > WorkSize Then
  76.   BufLen = WorkSize
  77. End If
  78. Code = SioGets(Port, WorkBuffer, BufLen)
  79. WorkLength = Code
  80. fGets = Code
  81. End Function
  82.  
  83. Public Function fInfo(ByVal Cmd As Long) As Long
  84. fInfo = SioInfo(Cmd)
  85. End Function
  86.  
  87. Public Function fParms(ByVal Port As Long, ByVal Code1 As Long, ByVal Code2 As Long, ByVal Code3 As Long) As Long
  88. fParms = SioParms(Port, Code1, Code2, Code3)
  89. End Function
  90.  
  91. Public Function fPutc(ByVal Port As Long, ByVal Char As Long) As Long
  92. fPutc = SioPutc(Port, Char)
  93. End Function
  94.  
  95. Public Function fPuts(ByVal Port As Long, ByVal Buffer As String, ByVal BufLen As Long) As Long
  96. fPuts = SioPuts(Port, Buffer, BufLen)
  97. End Function
  98.  
  99. Public Function fRead(ByVal Port As Long, ByVal Reg) As Long
  100. fRead = SioRead(Port, Reg)
  101. End Function
  102.  
  103. Public Function fReset(ByVal Port As Long, ByVal RxQueSize As Long, ByVal TxQueSize As Long) As Long
  104. fReset = SioReset(Port, RxQueSize, TxQueSize)
  105. End Function
  106.  
  107. Public Function fRI(ByVal Port As Long) As Long
  108. fRI = SioRI(Port)
  109. End Function
  110.  
  111. Public Function fRTS(ByVal Port As Long, ByVal Char As Long) As Long
  112. fRTS = SioRTS(Port, Char)
  113. End Function
  114.  
  115. Public Function fRxClear(ByVal Port As Long) As Long
  116. fRxClear = SioRxClear(Port)
  117. End Function
  118.  
  119. Public Function fRxQue(ByVal Port As Long) As Long
  120. fRxQue = SioRxQue(Port)
  121. End Function
  122.  
  123. Public Function fStatus(ByVal Port As Long, ByVal Mask As Long) As Long
  124. fStatus = SioStatus(Port, Mask)
  125. End Function
  126.  
  127. Public Function fTimer() As Long
  128. fTimer = SioTimer()
  129. End Function
  130.  
  131. Public Function fTxClear(ByVal Port As Long) As Long
  132. fTxClear = SioTxClear(Port)
  133. End Function
  134.  
  135. Public Function fTxQue(ByVal Port As Long) As Long
  136. fTxQue = SioRxQue(Port)
  137. End Function
  138.  
  139. Public Function fUnGetc(ByVal Port As Long, ByVal Char As Long) As Long
  140. fUnGetc = SioUnGetc(Port, Char)
  141. End Function
  142.  
  143. Public Function fWinError(ByVal BufLen As Long) As Long
  144. Dim Code As Long
  145. If BufLen > WorkSize Then
  146.   BufLen = WorkSize
  147. End If
  148. Code = SioWinError(WorkBuffer, BufLen)
  149. WorkLength = Code
  150. fWinError = Code
  151. End Function
  152.  
  153. Public Property Get ResultString() As String
  154. 'used when retrieving value of a property, on the right side of an assignment.
  155. 'Syntax: Debug.Print X.ResultString
  156.     ResultString = Left$(WorkBuffer,WorkLength)
  157. End Property
  158.  
  159. Private Sub Class_Initialize()
  160. WorkBuffer = ""
  161. WorkLength = 0
  162. End Sub
  163.