Shop OBEX P1 Docs P2 Docs Learn Events
Nested IF statements — Parallax Forums

Nested IF statements

John KauffmanJohn Kauffman Posts: 653
edited 2006-10-10 18:51 in General Discussion
In SX/B (IDE ver 3.2) is there a trick to nesting IF...THEN statements?
Doesn't seem to be a warning in the IDE help, but no examples of nested in help
I have searched forum for "nest if" and "nested if" but without results.
There is a nested example in the CLock/Timer sample.

This first one works fine:
if RB.3 = 1 then
· pause 1
endif


This second one fails, throwing a 26 error at the second EndIF (last line below)
if RB.3 = 1 then
pause 1
· ·if RB.4 = 1 then
······ pause 1
·· endif
endif
·
Error 26 from help:
attachment.php?attachmentid=74035

Comments

  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2006-10-10 17:16
    John,

    I am not aware of a 'trick' to nesting If...Then statements. I have nested many myself.

    I copied the code from your second example into the main program body of the example template from the help file. It compiled just fine for me. I am using SX-Key 3.2 and not yet the latest version that was made available within the last few days.

    - Sparks
  • BeanBean Posts: 8,129
    edited 2006-10-10 17:43
    John,
    Older versions of the compiler had a problem with lowercase commands (I think IF..THEN..ELSE..ENDIF were ones).
    Try either the latest compiler (1.51.03) or make them uppercase.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com

    Don't mistake experience for intelligence. And vis-vera.
    ·
  • John KauffmanJohn Kauffman Posts: 653
    edited 2006-10-10 18:51
    Correct, as always, Bean.
    Changing to upper case did the trick.
    I will check on 1.51.03 compiler tomorrow.

    BTW, is there a wish list kept somewhere for improvments to the user IDE interface?
Sign In or Register to comment.