Nested "Select Case"s


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1

    Default Nested "Select Case"s

    Are there any problems (besides being visually confusing) that one would encounter with nested "select case" routines, and if not, is there a limit to depth - i.e.- are 3 ok?

    Thanks

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,519


    Did you find this post helpful? Yes | No

    Default Re: Nested "Select Case"s

    No problems that I know of, have done it many times though not that many levels (2-3).
    I don't know if there's a limit, can't think of why there would be.

    /Henrik.

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: Nested "Select Case"s

    The only limit I can think of is the "stack". But that's most likely the same stack we use for GOSUBs and nobody has complained about a limitation on that yet.

    "Total deduction on my part without a shred of supporting evidence"

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default Re: Nested "Select Case"s

    A select case statement expands to a sequence of 'If This Then That' constructs when run through the compiler. Since there is no limitation using the If then, I do not anticipate a limit on the nesting of select case statements. Gosubs are in a different category wherein the compiler can decide to use the stack - or in some cases - to use gotos to acheive the same functionality and is totally compiler dependent.

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: Nested "Select Case"s

    Good to know, thanks!!

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: Nested "Select Case"s

    Quote Originally Posted by Jerson View Post
    ...Gosubs are in a different category wherein the compiler can decide to use the stack - or in some cases - to use gotos to acheive the same functionality and is totally compiler dependent.
    Ok, you got me on that one. How can GOTOs be used to achieve GOSUB logic?

    The going part is not a problem, but how does it come back without using a stack or some such memory to remember where it came from?

    Or does it replace the RETURN with a GOTO pointing to the statement following the GOSUB?

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  7. #7
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Nested "Select Case"s

    I dig many .LST files, and didn't see that compiler replaces GOSUB with GOTO.
    ON DEBUG uses GOTO after each PBP line, but before GOTO saves address to DEBUG_ADDRESS and, DEBUG_ADDRESSU variables. So you can use them to load program counter to get back from where PC jumped.

Similar Threads

  1. "select language" box at the top causes problems
    By Heckler in forum Forum Requests
    Replies: 2
    Last Post: - 22nd March 2016, 16:41
  2. Replies: 0
    Last Post: - 14th November 2013, 03:32
  3. Replies: 3
    Last Post: - 15th October 2012, 08:06
  4. Multiple "AND"'s in select case?
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 1st January 2010, 19:10
  5. "Select Case" Help
    By bmsherma in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th November 2009, 08:16

Members who have read this thread : 1

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