Shop OBEX P1 Docs P2 Docs Learn Events
Compound conditions with new IF/Else statement — Parallax Forums

Compound conditions with new IF/Else statement

ArchiverArchiver Posts: 46,084
edited 2003-08-04 23:01 in General Discussion
Hi all,

Does anybody know if you can use compound condition statements
with the new IF/Else (v2.5) statement? This code is acting real
strange, it will allow values of say "250" to drop thru the
first test and trigger the bad value else clause at the end of
the statement.

IF (IR_pulse(i) > 200 AND IR_pulse(i) < 350) THEN
IrMessage = IrMessage << 1
'--- test for 1 bit
ELSEIF (IR_pulse(i) > 550 AND IR_pulse(i) < 650) THEN
irMessage = (IrMessage << 1) + 1
ELSE
IrMessage = 0 <---- VALUES LIKE "250" ARE GETTING HERE!
DEBUG "Ir is bad -- ", DEC3 IR_pulse(i), CR
GOTO ScanIrExit
ENDIF

Is it me doing something stupid, or is there something else
going on here? Any help would be greatly appreciated. The
manual doesn't say explicitly that you can't, but only gives
examples of simple conditional tests.

Thanks,

Michael Burr

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-08-04 19:28
    Michael-

    What size variable (byte, word,...) is IR-pulse?

    Steve

    On 4 Aug 03 at 11:23, Michael Burr wrote:

    > Hi all,
    >
    > Does anybody know if you can use compound condition statements with
    > the new IF/Else (v2.5) statement? This code is acting real strange,
    > it will allow values of say "250" to drop thru the first test and
    > trigger the bad value else clause at the end of the statement.
    >
    > IF (IR_pulse(i) > 200 AND IR_pulse(i) < 350) THEN
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-04 19:34
    SELECT-CASE is probably better suited for what you're attempting to do:

    SELECT IR_pulse(i)
    CASE 200 TO 350
    IrMessage = IrMessage << 1
    CASE 550 TO 650
    irMessage = (IrMessage << 1) + 1
    CASE ELSE
    IrMessage = 0
    DEBUG "Ir is bad -- ", DEC3 IR_pulse(i), CR
    GOTO ScanIrExit
    ENDSELECT

    I don't see anything flawed in your logic, so I'm going to forward it to
    our Engineering staff.

    -- Jon Williams
    -- Parallax


    Original Message
    From: Michael Burr [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=mHAsoYv5Z2gjr3Aqe-c_cRzfdPzKH_9pO-GX8xqYzK_gPp6DuLVq22PN3r6rnn15kS_5bkXJ]mburr@b...[/url
    Sent: Monday, August 04, 2003 1:24 PM
    To: basicstamps@yahoogroups.com
    Subject: [noparse][[/noparse]basicstamps] Compound conditions with new IF/Else statement


    Hi all,

    Does anybody know if you can use compound condition statements
    with the new IF/Else (v2.5) statement? This code is acting real
    strange, it will allow values of say "250" to drop thru the
    first test and trigger the bad value else clause at the end of
    the statement.

    IF (IR_pulse(i) > 200 AND IR_pulse(i) < 350) THEN
    IrMessage = IrMessage << 1
    '--- test for 1 bit
    ELSEIF (IR_pulse(i) > 550 AND IR_pulse(i) < 650) THEN
    irMessage = (IrMessage << 1) + 1
    ELSE
    IrMessage = 0 <---- VALUES LIKE "250" ARE GETTING HERE!
    DEBUG "Ir is bad -- ", DEC3 IR_pulse(i), CR
    GOTO ScanIrExit
    ENDIF

    Is it me doing something stupid, or is there something else
    going on here? Any help would be greatly appreciated. The
    manual doesn't say explicitly that you can't, but only gives
    examples of simple conditional tests.

    Thanks,

    Michael Burr


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-04 19:34
    What is IR_Pulse(i) defined as, e.g., bit, byte, word...?

    On Monday, August 4, 2003, at 02:23 PM, Michael Burr wrote:

    > Hi all,
    >
    > Does anybody know if you can use compound condition statements
    > with the new IF/Else (v2.5) statement? This code is acting real
    > strange, it will allow values of say "250" to drop thru the
    > first test and trigger the bad value else clause at the end of
    > the statement.
    >
    > IF (IR_pulse(i) > 200 AND IR_pulse(i) < 350) THEN
    > IrMessage = IrMessage << 1
    > '--- test for 1 bit
    > ELSEIF (IR_pulse(i) > 550 AND IR_pulse(i) < 650) THEN
    > irMessage = (IrMessage << 1) + 1
    > ELSE
    > IrMessage = 0 <---- VALUES LIKE "250" ARE GETTING HERE!
    > DEBUG "Ir is bad -- ", DEC3 IR_pulse(i), CR
    > GOTO ScanIrExit
    > ENDIF
    >
    > Is it me doing something stupid, or is there something else
    > going on here? Any help would be greatly appreciated. The
    > manual doesn't say explicitly that you can't, but only gives
    > examples of simple conditional tests.
    >
    > Thanks,
    >
    > Michael Burr
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject
    > and Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-04 19:36
    S Parkis wrote:
    > Michael-
    >
    > What size variable (byte, word,...) is IR-pulse?
    >
    > Steve
    >

    Thanks for the response, IR_pulse is a 16-bit word.

    Michael
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-04 22:42
    Thanks for the input Jon and Jeff. I will double check a couple
    of things on my end and send Jeff a more complete piece of code
    if need be. Your Case example is another very good option.

    Btw: Is there a specific place to register issues with the new
    2.5 editor? I've come across a couple of items you might want
    on your to do list (one was an infinite loop that I had to kill
    the editor to get out of).

    Michael


    Jon Williams wrote:
    > SELECT-CASE is probably better suited for what you're attempting to do:
    >
    > SELECT IR_pulse(i)
    > CASE 200 TO 350
    > IrMessage = IrMessage << 1
    > CASE 550 TO 650
    > irMessage = (IrMessage << 1) + 1
    > CASE ELSE
    > IrMessage = 0
    > DEBUG "Ir is bad -- ", DEC3 IR_pulse(i), CR
    > GOTO ScanIrExit
    > ENDSELECT
    >
    > I don't see anything flawed in your logic, so I'm going to forward it to
    > our Engineering staff.
  • ArchiverArchiver Posts: 46,084
    edited 2003-08-04 23:01
    Yes. Please send your concerns to pbasic25beta@p....

    -- Jon Williams
    -- Parallax


    Original Message
    From: Michael Burr [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=bSTcG9oiarz8nEbgsilcCQKNsH90XsXkm6lxjkqmiGsHdjxFt4-mXZCCzU8_Z5AG5jmxSOBBIpse]mburr@b...[/url
    Sent: Monday, August 04, 2003 4:42 PM
    To: basicstamps@yahoogroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] Compound conditions with new IF/Else
    statement


    Thanks for the input Jon and Jeff. I will double check a couple
    of things on my end and send Jeff a more complete piece of code
    if need be. Your Case example is another very good option.

    Btw: Is there a specific place to register issues with the new
    2.5 editor? I've come across a couple of items you might want
    on your to do list (one was an infinite loop that I had to kill
    the editor to get out of).

    Michael


    Jon Williams wrote:
    > SELECT-CASE is probably better suited for what you're attempting to
    > do:
    >
    > SELECT IR_pulse(i)
    > CASE 200 TO 350
    > IrMessage = IrMessage << 1
    > CASE 550 TO 650
    > irMessage = (IrMessage << 1) + 1
    > CASE ELSE
    > IrMessage = 0
    > DEBUG "Ir is bad -- ", DEC3 IR_pulse(i), CR
    > GOTO ScanIrExit
    > ENDSELECT
    >
    > I don't see anything flawed in your logic, so I'm going to forward it
    > to our Engineering staff.


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject
    and Body of the message will be ignored.


    Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/




    This message has been scanned by WebShield. Please report SPAM to
    abuse@p....
Sign In or Register to comment.