Strange behaviour


Closed Thread
Results 1 to 6 of 6
  1. #1

    Exclamation Strange behaviour

    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

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Remove the brackets.

    Code:
    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.
    All progress began with an idea

  3. #3


    Did you find this post helpful? Yes | No

    Exclamation

    Hi Aratti
    I tried it with removing brackets as well but the problem is the same.

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Hi
    Any suggestion on this one?

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default

    Hi,
    How about:
    Code:
    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

  6. #6


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by HenrikOlsson View Post
    Hi,
    How about:
    Code:
    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.

Similar Threads

  1. Strange Behaviour - Simple code+DT_INT+16F676
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 17th February 2010, 18:53
  2. Strange Serout Behaviour
    By bluesmoke in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th August 2009, 04:12
  3. Strange ADC behaviour
    By ruijc in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 12th December 2007, 20:03
  4. Strange behaviour from PIC16F877 on TMR0
    By mikebar in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 19th August 2006, 01:31
  5. strange int behaviour
    By tom in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th November 2005, 15:41

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts