jessey
- 1st January 2008, 00:25
Hello Everyone,
I'm having problems with a Select Case routine that I'm hoping someone can help me understand why I can't get any If-Then-Else-Endif statements to work in it. I just modified the example program (remotext.bas) that came with my LAB-XT Telephony Experimenter's Board so that it will require the caller to enter an access number within a specified time in order to use the remote functions of the answering machine.
The Select Case below works good but if the caller doesn't enter "8", "9" or "0" then he could try different sequences of the remaining numbers and possibly gain access. I'd like to be able to use "If-Then-Else-Endif" statements so that if any of the remaining numbers are pressed out of sequence then the variable for that number will be set to 2 which would make it impossible to gain access unless the caller hangs up then try's again. I'd like to be able to use this If-Then-Else-Endif below for all the Case statements but for some reason that I can't figure out, it just won't work? I even tried using GOSUB's to use the If-Then-Else-Endif's but still no go. I'm including the whole program in an attachment if that'll help. Any help will be greatly appreciated.
Thanks
jessey
Case "1"
IF (A=0) AND (B=1) AND (C=1) AND (D=1) AND _
(E=1) AND (F=0) AND (G=1) THEN
A=1
ELSE
A=2
ENDIF
This works but I'd like to be able to add If-Then-Else-Endif's
Enter_Access_Code:
select_dtmf = 1 ' Enable the data output from the MT8870
Pause 1 ' Pause 1 mS to let data settle
dtmf_digit = (PORTB >> 4) ' Read the top nibble of PORTB for DTMF data
' Use LOOKUP to change the DTMF data to an ASCII character
LookUp dtmf_digit, ["_1234567890*#ABCD"], dtmf_digit
dtmf_wait2:
IF dtmf_ready Then dtmf_wait2 ' Loop here until DTMF signal stops
select_dtmf = 0 ' Disable the MT8870 data output
' access code is 2457316
Select Case dtmf_digit ' Take action based on the dtmf digit
'6th # in the correct sequence --- 1 = A
Case "1"
IF (A=0) AND (B=1) AND (C=1) AND (D=1) AND _
(E=1) AND (F=0) AND (G=1) THEN A=1
'1st # in the correct sequence --- 2 = B
Case "2"
IF (A=0) AND (B=0) AND (C=0) AND (D=0) AND _
(E=0) AND (F=0) AND (G=0) THEN B=1
'5th # in the correct sequence --- 3 = C
Case "3"
IF (A=0) AND (B=1) AND (C=0) AND (D=1) AND _
(E=1) AND (F=0) AND (G=1) THEN C=1
'2nd # in the correct sequence --- 4 = D
Case "4"
IF (A=0) AND (B=1) AND (C=0) AND (D=0) AND _
(E=0) AND (F=0) AND (G=0) THEN D=1
'3rd # in the correct sequence --- 5 = E
Case "5"
IF (A=0) AND (B=1) AND (C=0) AND (D=1) AND _
(E=0) AND (F=0) AND (G=0) THEN E=1
'7th # in the correct sequence --- 6 = F
Case "6"
IF (A=1) AND (B=1) AND (C=1) AND (D=1) AND _
(E=1) AND (F=0) AND (G=1) THEN F=1
'4th # in the correct sequence --- 7 = G
Case "7"
IF (A=0) AND (B=1) AND (C=0) AND (D=1) AND _
(E=1) AND (F=0) AND (G=0) THEN G=1
Case "8"
A=2 ' If the #8 key is pressed then it's a no go
Case "9"
A=2 ' If the #9 key is pressed then it's a no go
Case "0"
A=2 ' If the #0 key is pressed then it's a no go
End Select
IF (A=1) AND (B=1) AND (C=1) AND (D=1) AND _
(E=1) AND (F=1) AND (G=1) THEN
access_code = is_verified ' remote functions will work now
FreqOut DTMF_out, 500, 800 ' Play 3 tones to confirm to the caller that
PAUSE 100 ' the correct access code has been entered
FreqOut DTMF_out, 500, 800
PAUSE 100
FreqOut DTMF_out, 500, 800
ENDIF
IF k = 0 THEN listen
I'm having problems with a Select Case routine that I'm hoping someone can help me understand why I can't get any If-Then-Else-Endif statements to work in it. I just modified the example program (remotext.bas) that came with my LAB-XT Telephony Experimenter's Board so that it will require the caller to enter an access number within a specified time in order to use the remote functions of the answering machine.
The Select Case below works good but if the caller doesn't enter "8", "9" or "0" then he could try different sequences of the remaining numbers and possibly gain access. I'd like to be able to use "If-Then-Else-Endif" statements so that if any of the remaining numbers are pressed out of sequence then the variable for that number will be set to 2 which would make it impossible to gain access unless the caller hangs up then try's again. I'd like to be able to use this If-Then-Else-Endif below for all the Case statements but for some reason that I can't figure out, it just won't work? I even tried using GOSUB's to use the If-Then-Else-Endif's but still no go. I'm including the whole program in an attachment if that'll help. Any help will be greatly appreciated.
Thanks
jessey
Case "1"
IF (A=0) AND (B=1) AND (C=1) AND (D=1) AND _
(E=1) AND (F=0) AND (G=1) THEN
A=1
ELSE
A=2
ENDIF
This works but I'd like to be able to add If-Then-Else-Endif's
Enter_Access_Code:
select_dtmf = 1 ' Enable the data output from the MT8870
Pause 1 ' Pause 1 mS to let data settle
dtmf_digit = (PORTB >> 4) ' Read the top nibble of PORTB for DTMF data
' Use LOOKUP to change the DTMF data to an ASCII character
LookUp dtmf_digit, ["_1234567890*#ABCD"], dtmf_digit
dtmf_wait2:
IF dtmf_ready Then dtmf_wait2 ' Loop here until DTMF signal stops
select_dtmf = 0 ' Disable the MT8870 data output
' access code is 2457316
Select Case dtmf_digit ' Take action based on the dtmf digit
'6th # in the correct sequence --- 1 = A
Case "1"
IF (A=0) AND (B=1) AND (C=1) AND (D=1) AND _
(E=1) AND (F=0) AND (G=1) THEN A=1
'1st # in the correct sequence --- 2 = B
Case "2"
IF (A=0) AND (B=0) AND (C=0) AND (D=0) AND _
(E=0) AND (F=0) AND (G=0) THEN B=1
'5th # in the correct sequence --- 3 = C
Case "3"
IF (A=0) AND (B=1) AND (C=0) AND (D=1) AND _
(E=1) AND (F=0) AND (G=1) THEN C=1
'2nd # in the correct sequence --- 4 = D
Case "4"
IF (A=0) AND (B=1) AND (C=0) AND (D=0) AND _
(E=0) AND (F=0) AND (G=0) THEN D=1
'3rd # in the correct sequence --- 5 = E
Case "5"
IF (A=0) AND (B=1) AND (C=0) AND (D=1) AND _
(E=0) AND (F=0) AND (G=0) THEN E=1
'7th # in the correct sequence --- 6 = F
Case "6"
IF (A=1) AND (B=1) AND (C=1) AND (D=1) AND _
(E=1) AND (F=0) AND (G=1) THEN F=1
'4th # in the correct sequence --- 7 = G
Case "7"
IF (A=0) AND (B=1) AND (C=0) AND (D=1) AND _
(E=1) AND (F=0) AND (G=0) THEN G=1
Case "8"
A=2 ' If the #8 key is pressed then it's a no go
Case "9"
A=2 ' If the #9 key is pressed then it's a no go
Case "0"
A=2 ' If the #0 key is pressed then it's a no go
End Select
IF (A=1) AND (B=1) AND (C=1) AND (D=1) AND _
(E=1) AND (F=1) AND (G=1) THEN
access_code = is_verified ' remote functions will work now
FreqOut DTMF_out, 500, 800 ' Play 3 tones to confirm to the caller that
PAUSE 100 ' the correct access code has been entered
FreqOut DTMF_out, 500, 800
PAUSE 100
FreqOut DTMF_out, 500, 800
ENDIF
IF k = 0 THEN listen