home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Eagles Nest BBS 6
/
Eagles_Nest_Mac_Collection_Disc_6.TOAST
/
Windows
/
VisBasAPIex
/
VBAPIGUIDE.image
/
COMMDEMO.FRM
< prev
next >
Wrap
Text File
|
1992-10-11
|
4KB
|
138 lines
VERSION 2.00
Begin Form CommDemo
Caption = "Communications Demo - Mini Terminal"
Height = 5595
Left = 915
LinkMode = 1 'Source
LinkTopic = "Form1"
ScaleHeight = 4905
ScaleWidth = 8400
Top = 1155
Width = 8520
Begin TextBox TermText
FontBold = 0 'False
FontItalic = 0 'False
FontName = "Fixedsys"
FontSize = 9
FontStrikethru = 0 'False
FontUnderline = 0 'False
Height = 4095
Left = 120
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
Top = 600
Width = 8175
End
Begin ccCallback Callback1
Left = 7800
Top = 120
End
Begin Menu MenuConfigure
Caption = "Configure"
End
Begin Menu MenuDial
Caption = "Dial"
End
End
Sub Callback1_CommEvent (DeviceID As Integer, NotifyStatus As Integer)
Dim t$
Dim textlen%
Dim cstat As COMSTAT
Dim crloc%
Dim use$
Dim cpos%
If NotifyStatus And CN_EVENT Then
di% = GetCommError(DeviceID, cstat)
If di% <> 0 And Dialing% Then
' Check for connect fallback
If InStr(TermText.Text, "CONNECT 1200") <> 0 Then
PortConfig.BaudRate = 1200
di% = SetCommState(PortConfig)
End If
Dialing% = 0
Else
MsgBox "Communication Error Occured - " + Hex$(di%)
End If
' Clear the error event mask
dl& = GetCommEventMask(CommID%, EV_ERR)
End If
t$ = GetChars$()
use$ = ""
If t$ <> "" Then
' Substitute the CR with a CRLF pair, dump the LF
For cpos% = 1 To Len(t$)
Select Case Asc(Mid$(t$, cpos%))
Case 13
use$ = use$ + Chr$(13) + Chr$(10)
Case 10
' Dump the line feeds
Case Else
use$ = use$ + Mid$(t$, cpos%, 1)
End Select
Next cpos%
TermText.SelStart = Len(TermText.Text)
TermText.SelLength = 0
TermText.SelText = use$
If Len(TermText.Text) > 4096 Then
TermText.Text = Right$(TermText.Text, 2048)
End If
TermText.SelStart = Len(TermText.Text)
End If
End Sub
'
' We open the port and get things started here
'
Sub Form_Load ()
' We load the configuration form so that the default
' settings can be read by OpenThePort
Load CommCfg
TermText.Move 0, 0, ScaleWidth, ScaleHeight
CommID% = -1
CommNum% = -1
OpenThePort
End Sub
Sub Form_Resize ()
TermText.Move 0, 0, ScaleWidth, ScaleHeight
End Sub
'
' This routine performs necessary cleanup
'
Sub Form_Unload (Cancel As Integer)
If CommID% <> -1 Then
di% = EnableCommNotification(CommID%, 0, 0, 0)
di% = CloseComm%(CommID%)
End If
End Sub
Sub MenuConfigure_Click ()
CommCfg.Show 1
End Sub
Sub MenuDial_Click ()
Dim dnum$
TermText.Text = ""
dnum$ = InputBox$("Enter number to dial", "Dialer")
SendChars "ATTD" + dnum$ + Chr$(13)
Dialing% = -1
End Sub
Sub TermText_KeyPress (KeyAscii As Integer)
SendChars Chr$(KeyAscii)
KeyAscii = 0
End Sub