Public port
Private Sub Command1_Click()
Close
Open "c:\clid\clid.prt" For Output As #1
If Option1.Value = True Then
Print #1, "1"
Else
Print #1, "2"
End If
End
End Sub
Private Sub Command2_Click()
Form1.WindowState = 1
End Sub
Private Sub Command3_Click()
If Text1.Text <> "" Then
Open "c:\clid\clid.dat" For Append As #1
Print #1, Text1.Text; Spc(50 - (Len(Text1.Text))); Mid$(List1.List(List1.ListIndex), 11, 10)
Close #1
Label2.Visible = False
Label3.Visible = False
Text1.Visible = False
List1.Visible = True
Command1.Visible = True
Command2.Visible = True
Command3.Visible = False
Text1.Text = ""
End If
End Sub
Private Sub Form_Load()
Label2.Visible = False
Label3.Visible = False
Text1.Visible = False
Command3.Visible = False
Open "c:\clid\clid.prt" For Input As #1
Line Input #1, prt$
If prt$ = "1" Then
Option1.Value = True
Else
Option2.Value = True
End If
Close #1
' This is a sample program. By no means the author can be held responsible
' for damage caused by this program. By using this program you agree with
' this terms. USE AT YOUR OWN RISC if your pc will implode or explode your in
' bad luck ;-)
' Dit is een demonstratie programma. Het gebruik van dit programma is geheel
' voor EIGEN RISICO.
' Auteur kan niet aansprakelijk gehouden worden voor schade (van welke aard
' dan ook ) resulterende uit het gebruik van dit programma. Tevens kan auteur
' niet aansprakelijk worden gehouden voor fouten in het programma en of
' door operator gemaakte fouten.
' Door dit programma te gebruiken stemt U in met deze voorwaarden.
' LET OP : Sluit nooit iets aan op de printerpoort terwijl de pc of het appa-
' raat wat u wilt aansluiten aanstaat.
valid = 0
Form1.WindowState = 1 'start minimized
'Print
'Print "Tijd Naam Nummer"
'Print "-------------------------------------------------------------------"
Do While True
' Here the subroutine is called which decodes the values received by the
' decoder.
listen nr$, valid
' The following code will search a file for the received phonenumber.
' If found the number will be dislayed on the screen with the corresponding
' name. If not found Onbekend with the received number will be displayed.
If valid = 1 Then
Open "c:\clid\clid.dat" For Input As #2
tmp$ = "begin"
naam$ = "Onbekend "
Do While Not EOF(2)
Line Input #2, tmp$
nrtmp$ = Mid$(tmp$, 51)
'check for -. or space in number
If InStr(nrtmp$, "-") Then
nrtmp1$ = Left$(nrtmp$, (InStr(nrtmp$, "-") - 1))
nrtmp1$ = nrtmp1$ + Mid$(nrtmp$, (InStr(nrtmp$, "-") + 1))
nrtmp$ = nrtmp1$
End If
If InStr(nrtmp$, ".") Then
nrtmp1$ = Left$(nrtmp$, (InStr(nrtmp$, ".") - 1))
nrtmp1$ = nrtmp1$ + Mid$(nrtmp$, (InStr(nrtmp$, ".") + 1))
nrtmp$ = nrtmp1$
End If
If InStr(nrtmp$, " ") Then
nrtmp1$ = Left$(nrtmp$, (InStr(nrtmp$, " ") - 1))
nrtmp1$ = nrtmp1$ + Mid$(nrtmp$, (InStr(nrtmp$, " ") + 1))
nrtmp$ = nrtmp1$
End If
If InStr(nrtmp$, nr$) Then
naam$ = Left$(tmp$, 50)
End If
Loop
Close #2
List1.AddItem (Time$ & " " & nr$ & " " & naam$), 0
valid = 0
mstmp$ = Time$ & " " & nr$ & " " & naam$
Form1.WindowState = 2
Form1.Show
Open "c:\clid\clid.log" For Append As #2
Print #2, Date$ & " " & Time$ & " " & nr$ & " " & naam$
Close #2
End If
Loop
End Sub
Static Sub listen(nr$, valid)
Static btime
nr$ = ""
Form1.Show
i = Inp(port) '379 for lpt1 279 for lpt2
Do While (i And 64) = 64 'While STD is high read decoded DTMF signal
i = Inp(port)
DoEvents
Loop
valid = 0 ' Indicator for receiving a complete number.
' A complete number begins with a 'D' then the numerals and ends with a 'C'
If (i And 184) = &H8 Then a$ = a$ + "9"
If (i And 184) = &H10 Then a$ = a$ + "0"
If (i And 184) = &H18 Then a$ = a$ + "*"
If (i And 184) = &H20 Then a$ = a$ + "#"
If (i And 184) = &H28 Then
a$ = ""
btime = Now 'a$ + "A"
End If
If (i And 184) = &H30 Then
a$ = ""
btime = Now 'a$ + "B"
End If
If (i And 184) = &H80 Then
a$ = ""
btime = Now ' A 'D' was received. Clear nr$ for reception of new number
End If
If (i And 184) = &H88 Then a$ = a$ + "1"
If (i And 184) = &H90 Then a$ = a$ + "2"
If (i And 184) = &H98 Then a$ = a$ + "3"
If (i And 184) = &HA0 Then a$ = a$ + "4"
If (i And 184) = &HA8 Then a$ = a$ + "5"
If (i And 184) = &HB0 Then a$ = a$ + "6"
If (i And 184) = &HB8 Then a$ = a$ + "7"
If (i And 184) = &H0 Then a$ = a$ + "8"
Do While (i And 64) = 0 'While no new data wait (STD==LOW)
i = Inp(port)
DoEvents
Loop
If (i And 184) = &H38 Then
' A 'C' is received. The number is complete and
' will be returned to the calling application.
If DateDiff("s", btime, Now) <= 3 Then ' is het nummer binnen 2 sec ontvangen ?
nr$ = a$
a$ = ""
valid = 1
Exit Sub
Else
nr$ = ""
a$ = ""
End If
End If
End Sub
Private Sub List1_DblClick()
List1.Visible = False
Command1.Visible = False
Command2.Visible = False
Label2.Visible = True
Text1.Visible = True
Text1.SetFocus
Label3.Visible = True
Command3.Visible = True
End Sub
Private Sub Option1_Click()
port = &H379
End Sub
Private Sub Option2_Click()
port = &H279
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Command3.Value = True
End If
End Sub