If endif loop with 'OR'


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: If endif loop with 'OR'

    That's a good point. What does happen first, the comparison or the subtraction, in the first snippet. In the second you'd be sure the subtraction was done prior to the comparison. I'm sure I'll get schooled here but with code there is often no such thing as overkilled overkill.

  2. #2
    Join Date
    Jan 2013
    Posts
    64


    Did you find this post helpful? Yes | No

    Default Re: If endif loop with 'OR'

    Hi,

    In my case the subtraction happens first.

    C.

  3. #3
    Join Date
    Sep 2010
    Location
    Las Vegas, NV
    Posts
    305


    Did you find this post helpful? Yes | No

    Default Re: If endif loop with 'OR'

    At least for C languages this, according to wikipedia, is the order of operations. I tried to find something more specific to PBP or the BASIC stamp but couldn't. This topic may be getting off topic but I thought it interesting to know at least a pseudo answer.


    1 () [] -> . :: Function call, scope, array/member access
    2 ! ~ - + * & sizeof type cast ++ -- (most) unary operators, sizeof and type casts (right to left)
    3 * / % MOD Multiplication, division, modulo
    4 + - Addition and subtraction
    5 << >> Bitwise shift left and right
    6 < <= > >= Comparisons: less-than, ...
    7 == != Comparisons: equal and not equal
    8 & Bitwise AND
    9 ^ Bitwise exclusive OR (XOR)
    10 | Bitwise inclusive (normal) OR
    11 && Logical AND
    12 || Logical OR
    13 ? : Conditional expression (ternary)
    14 = += -= *= /= %= &= |= ^= <<= >>= Assignment operators (right to left)
    15 , Comma operator

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


    Did you find this post helpful? Yes | No

    Default Re: If endif loop with 'OR'

    Precedence from the pbp3 manual

    The following table lists the operators in default hierarchal order. (Parentheses will
    override.) Operators with the same precedence level (on the same line in the table
    below) will be evaluated in the order (left to right) that they are encountered in the
    written expression.
    Highest Precedence
    ( ) (anything enclosed in parentheses)
    - (unary)
    ! or NOT, ABS, COS, DCD, DIV32, NCD, SIN, SQR
    <<, >>, ATN, DIG, HYP, MAX, MIN, REV
    *, /, **, */, //
    +, - (in math), ~
    = or ==, <> or !=, <, <=, >, >=
    &, |, ^, &/, |/, ^/
    AND, OR, XOR, ANDNOT, ORNOT, XORNOT
    Lowest Precedence

    camerart's problem is that he is using Oshonsoft's version of picbasic not pbppro

    picbasic != pbppro

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