IF-THEN what?


Closed Thread
Results 1 to 11 of 11

Thread: IF-THEN what?

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,116

    Default IF-THEN what?

    Well, I am embarrased to have this asked, but maybe my coffee is not strong enough.

    Isn't these two totally equivalent?

    Code:
    IF w1>A THEN
        IF w1<B THEN
            DO SOMETHING
        ENDIF
    ENDIF
    Code:
     
    IF w1>A AND w1<B THEN DO SOMETHING
    They do not respond as expected. I mean as the second snipet.

    Ioannis

  2. #2
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default Re: IF-THEN what?

    Both work here.
    Code:
    A=5:B=10:w1=7
    
    If w1>A And w1<B 
       Debug "w1>A And w1<B"
    EndIf
    
    If w1>A 
      If w1<B 
        Debug "w1>A And w1<B" 
       EndIf
    EndIf

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,605


    Did you find this post helpful? Yes | No

    Default Re: IF-THEN what?

    Hi,
    I tried it here as well and they both seem to do the same thing... I tried with W1 less than A, bigger than B and within the range, both routines responded in the same way, what are you getting?

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,116


    Did you find this post helpful? Yes | No

    Default Re: IF-THEN what?

    Thanks for the replies. Well, I was testing a code for decoding RF remotes based on the MM53200/UM3750 or HT12 transmission protocol.

    The code with the AND in the IF-THEN statements works fine.

    The other with the nested IF-THENs does not.

    Mystery...

    Me too think that both codes are equivalent.

    Ioannis

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: IF-THEN what?

    It reminds me some weird stuff I already experimented in the past, memory leak or whatsoever, run CCLeaner, and reboot. this should do the trick.

    Out of curiosity, are you using MCSP or MPLAB?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,116


    Did you find this post helpful? Yes | No

    Default Re: IF-THEN what?

    Thanks Steve. I am using MCSP and Pickit2 with Stand Alone Driver.

    You are right about the weird things. I had some in the past for un-explained reasons.

    Will see.

    Ioannis

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,116


    Did you find this post helpful? Yes | No

    Default Re: IF-THEN what?

    OK. I think Steve was right.

    I have this test code on a Dropbox folder in order to work on different PCs. On a freshly boot PC, guess what. Works OK!

    How can a reboot make a program running as expected (or not...) ?

    Ioannis

    P.S. Maybe it is a tough one for Darrel

Members who have read this thread : 0

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