home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / WIN / Programa / WSC4VB10.ZIP / SIMPLINE.BAS < prev    next >
Encoding:
BASIC Source File  |  1996-08-25  |  3.2 KB  |  143 lines

  1. ' SIMPLINE.BAS
  2.  
  3. Option Explicit
  4.  
  5. Dim FatalFlag As Integer
  6. Dim Code As Integer
  7.  
  8. Sub Aborting ()
  9.   Dim Code As Integer
  10.   SIMPLE.Print "Fatal Error, Aborting..."
  11.   Code = SioDone(ThePort)
  12.   End
  13. End Sub
  14.  
  15. Sub DisplayChar (ByVal C As Integer)
  16.   Dim Row As Integer
  17.   Dim Col As Integer
  18.   C = &H7F And C
  19.   'process char
  20.   If C = 13 Then
  21.     'carriage control
  22.     CurrentCol = 0
  23.     'plus assumed line feed
  24.     If CurrentRow < 23 Then
  25.       CurrentRow = CurrentRow + 1
  26.       'print CR+LF
  27.       SIMPLE.Print
  28.     Else
  29.       'scroll !
  30.       SIMPLE.Cls
  31.       For Row = 0 To 22
  32.         'print row
  33.         ScreenBuffer(Row) = ScreenBuffer(Row + 1)
  34.         SIMPLE.Print ScreenBuffer(Row)
  35.       Next Row
  36.       'clear bottom row
  37.       ScreenBuffer(23) = Space$(80)
  38.     End If
  39.   ElseIf C = 10 Then
  40.     'throw away line feeds
  41.   Else
  42.     'not CR or LF
  43.     CurrentCol = CurrentCol + 1
  44.     If CurrentCol > 79 Then
  45.       'throw away !
  46.       Exit Sub
  47.     Else
  48.       'save in screen buffer & display
  49.       Mid$(ScreenBuffer(CurrentRow), CurrentCol, 1) = Chr$(C)
  50.       SIMPLE.Print Chr$(C);
  51.     End If
  52.   End If
  53. End Sub
  54.  
  55. Sub DisplayString (Text As String)
  56.   Dim i As Integer
  57.   Dim Length As Integer
  58.   Length = Len(Text)
  59.   For i = 1 To Length
  60.     Call DisplayChar(Asc(Mid$(Text, i, 1)))
  61.   Next i
  62.   Call DisplayChar(13)
  63. End Sub
  64.  
  65. Sub GetIncoming ()
  66.   Dim i As Integer
  67.   Dim Buffer As String * 1024
  68.   Dim Count As Integer
  69.   Count = SioGets(ThePort, Buffer, 1024)
  70.   If Count > 0 Then
  71.     For i = 1 To Count
  72.       Call DisplayChar(Asc(Mid$(Buffer, i, 1)))
  73.     Next i
  74.   End If
  75. End Sub
  76.  
  77. Sub GoOffLine ()
  78.   Dim Code As Integer
  79.   OnLineFlag = 0
  80.   'shut down port
  81.   Code = SioDone(ThePort)
  82. End Sub
  83.  
  84. Sub GoOnLine ()
  85.   Dim i As Integer
  86.   Dim RxQueSize As Integer
  87.   Dim TxQueSize As Integer
  88.   If OnLineFlag Then
  89.     Exit Sub
  90.   End If
  91.   'reset the port (1024 byte RX buffer & 128 byte TX buffer)
  92.   RxQueSize = 1024
  93.   TxQueSize = 128
  94.   Code = SioReset(ThePort, RxQueSize, TxQueSize)
  95.   If Code < 0 Then
  96.     Call SayError(SIMPLE, Code)
  97.     Exit Sub
  98.   End If
  99.   'set baud rate
  100.   Code = SioBaud(ThePort, TheBaudCode)
  101.   'call Aborting() if detect error after resetting port
  102.   Call DisplayString("COM" + LTrim$(Str$(1 + ThePort)) + " reset")
  103.   'set DTR & RTS
  104.   Code = SioDTR(ThePort, Asc("S"))
  105.   Code = SioRTS(ThePort, Asc("S"))
  106.   'turn on hardware flow control
  107.   Code = SioFlow(ThePort, Asc("H"))
  108.   Call DisplayString("RTS/CTS flow control on")
  109.   ' set parms
  110.   Code = SioParms(ThePort, TheParity, TheStopBits, TheDataBits)
  111.   ' we're online !
  112.   OnLineFlag = 1
  113. End Sub
  114.  
  115. Sub SetBaud ()
  116. Dim Code As Integer
  117. 'Baudrate can be changed while running
  118. Code = SioBaud(ThePort, TheBaudCode)
  119. End Sub
  120.  
  121. Sub ShowConfig ()
  122.   Dim A As String
  123.   Dim B As String
  124.   Dim C As String
  125.   Dim D As String
  126.   Dim E As String
  127.   If OnLineFlag Then
  128.     A = " (Online)"
  129.   Else
  130.     A = " (Offline)"
  131.   End If
  132.   B = "COM" + LTrim$(Str$(ThePort + 1))
  133.   C = " @ " + BaudRateTable(TheBaudCode) + " "
  134.   D = Str$(TheDataBits) + ParityText(TheParity)
  135.   If TheStopBits = 0 Then
  136.     E = "1"
  137.   Else
  138.     E = "2"
  139.   End If
  140.   SIMPLE.Caption = "SIMPLE: " + B + C + D + E + A
  141. End Sub
  142.  
  143.