If endif loop with 'OR'


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: If endif loop with 'OR'

    There’s nothing wrong with what you’re doing with the IF/THEN statements
    so long as you follow it, the compiled code is similar, and possiblly even worse.

    Code:
    if (battery=charged) && (lightbulb != blown) then ‘ AND
    bulb will light
    endif
    
    if (battery = flat) || (lightbulb = blown) then ‘ OR
    bulb will not light
    endif

  2. #2
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: If endif loop with 'OR'

    Hi Art,

    As I've been monolingual with basic since the early 80s, your reply is another puzzle, but thanks. I'll stick to IF/THEN.

    C.

  3. #3
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: If endif loop with 'OR'

    Ah, what I posted should compile in C or PBP, and in both languages inner brackets should evaluate first, and in order toward outer brackets.

    PBP
    Code:
    if (battery=charged) && (lightbulb != blown) then ‘ AND
    bulb will light
    endif
    C
    Code:
    if (battery=charged) && (lightbulb != blown) { ‘ AND
    bulb will light
    }




    Quote Originally Posted by camerart View Post
    Hi Art,

    As I've been monolingual with basic since the early 80s, your reply is another puzzle, but thanks. I'll stick to IF/THEN.

    C.

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,635


    Did you find this post helpful? Yes | No

    Default Re: If endif loop with 'OR'

    Ah, what I posted should compile in C or PBP, and in both languages inner brackets should evaluate first, and in order toward outer brackets.

    C

    if (battery=charged) && (lightbulb != blown) { ‘ AND bulb will light }
    not really in C (battery=charged) is not a comparison it's an assignment ,while the statement will compile in C the results will be incorrect

    (battery==charged) is a comparison statement in C

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: If endif loop with 'OR'

    Whoops .

Similar Threads

  1. Exit from an IF/ENDIF loop with a GOTO
    By aratti in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 17th February 2014, 13:05
  2. Replies: 2
    Last Post: - 28th July 2011, 16:23
  3. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23
  4. Problems with IF ENDIF
    By jetpr in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd November 2005, 16:10

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