PDA

View Full Version : Strange behaviour



financecatalyst
- 7th October 2009, 18:28
Hi
My program is as follows:

If sms[0]="a" and sms[1]="c" and sms[2]="t" then ' Statement 1
If (sms[0]="a"or"A") and (sms[1]="c"or"C") and (sms[2]="t"or"T") then ' Statement 2
for c=1 to 30
pause 100
toggle portb.6
pause 100
next c
endif

If sms[0]="d" and sms[1]="e" and sms[2]="a" and sms[3]="c" and sms[4]="t" then 'Statement 3
If (sms[0]="d"or"D") and (sms[1]="e"or"E") and (sms[2]="a"or"A") and (sms[3]="c"or"C") and (sms[4]="t"or"T") then ' Statement 4
for c=1 to 30
pause 500
toggle portb.6
pause 500
next c
endif

Problem:
I only use either statement 1 or 2 AND 3 or 4. Now when I use statement 1 & 3, the program works fine BUT when I use statement 2 & 4, the program keeps entering statement 2 even if statement 4 is valid!

Can someone help me understand why this is happening?
Thanks

aratti
- 7th October 2009, 18:52
Remove the brackets.


If sms[0]="d" or "D" and sms[1]="e" or "E" and sms[2]="a" or "A" and sms[3]="c" or"C" and sms[4]="t" or"T" then ' Statement 4

Al.

financecatalyst
- 7th October 2009, 18:59
Hi Aratti
I tried it with removing brackets as well but the problem is the same.

financecatalyst
- 8th October 2009, 00:35
Hi
Any suggestion on this one?

HenrikOlsson
- 8th October 2009, 06:13
Hi,
How about:

If (sms[0]="a" OR sms[0]="A") AND (sms[1]="c" OR sms[1]="C") AND (sms[2]="t" OR sms[2]="T") then

financecatalyst
- 8th October 2009, 22:35
Hi,
How about:

If (sms[0]="a" OR sms[0]="A") AND (sms[1]="c" OR sms[1]="C") AND (sms[2]="t" OR sms[2]="T") then

Thanks buddy. It worked. I was going crazy with this otherwise.