Shop OBEX P1 Docs P2 Docs Learn Events
Case statement limits — Parallax Forums

Case statement limits

ArchiverArchiver Posts: 46,084
edited 2003-02-10 02:44 in General Discussion
Hi all,

Is there a maximum number of case statements in a row? I have 10 cases, and
after number 7 it says "too complex".

Thanks,

Jonathan

www.madlabs.info

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-02-10 02:44
    >Is there a maximum number of case statements in a row? I have 10 cases, and
    >after number 7 it says "too complex".
    >Thanks,
    >Jonathan
    >www.madlabs.info

    The Stamp has an 8-level expression stack. The error message,
    "expression too complex" occurs when you use up all 8 levels and
    more. (Is that the error message you got?

    For example,

    y var word
    y=1+2+3+4+5+6+7+8+9 ' that only uses 2 levels, no problem
    y=1+(2+(3+(4+(5+(6+(7+(8+9))))))) ' needs 9 levels in PBASIC
    ' TOO COMPLEX

    (The example is from Brian Forbes' excellent book on Stamp internals.
    <http://members.aol.com/stamp2book/>)

    The plain IF-THEN command in the old PBASIC puts at least 2 arguments
    onto the expression stack, and more if you use a complicated
    expression for the condition. BRANCH, I think used only one
    location, but you could use complex expressions for the Branch
    arguments.

    I'm not sure how the CASE statement is implemented in the new PBASIC,
    but it would probably parse out to a bunch of IF-THEN's or BRANCH's.
    Look at your expressions to see how they could be simplified.

    -- Tracy
Sign In or Register to comment.