Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:02 12 Jan 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Picomite SELECT…CASE structure

Author Message
terekgabor
Newbie

Joined: 02/01/2026
Location: Hungary
Posts: 9
Posted: 02:47pm 10 Jan 2026
Copy link to clipboard 
Print this post

Hello!

I am using SELECT..CASE structure, after a number of CASE I get Not enough memory error.
Is there a maximum number of CASE pieces?
I use SELECT on a string variable for a command line editor.

Maybe better to switch back to IF-ELSEIF?


Thanks!
 
Peter63
Senior Member

Joined: 28/07/2017
Location: Sweden
Posts: 116
Posted: 04:25pm 10 Jan 2026
Copy link to clipboard 
Print this post

Hello

I made a simple test program, it actually stops with Error: Not enough memory ... hmmm

Maybe 64 is the maximum case test... ???

Using:

WebMite MMBasic RP2350A Edition V6.02.00RC0
OPTION SYSTEM SPI GP10,GP11,GP12
OPTION FLASH SIZE 4194304
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 200000
OPTION SDCARD GP15


  Quote  
'
' select case - test program
'
'
'

Do

Input "input string";s$

Select Case s$
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
 Case "1"
 Print "1"
End Select

Loop


End


/Peter63
 
Peter63
Senior Member

Joined: 28/07/2017
Location: Sweden
Posts: 116
Posted: 04:40pm 10 Jan 2026
Copy link to clipboard 
Print this post

Hello

Reading the manual page 33... maybe 50 is the limit ???

  Quote  
Recursion
Recursion is where a subroutine or function calls itself.  You can do recursion in MMBasic but there are a
number of issues (these are a direct consequence of the limitations of microcontrollers and the BASIC
language):
 There is a fixed limit to the depth of recursion.  In the PicoMite firmware this is 50 levels.  
 If you have many arguments to the subroutine or function and many LOCAL variables (especially strings)
you could easily run out of memory before reaching the 50 level limit.
 Any FOR…NEXT loops and DO…LOOPs will be corrupted if the subroutine or function is recursively
called from within these loops.


/Peter63
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4193
Posted: 04:59pm 10 Jan 2026
Copy link to clipboard 
Print this post

  terekgabor said  I am using SELECT..CASE structure, after a number of CASE I get Not enough memory error.

After how many?

Which CPU etc?

John
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 556
Posted: 05:09pm 10 Jan 2026
Copy link to clipboard 
Print this post

Maybe you need to rethink the way you are implementing the feature
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2716
Posted: 06:54pm 10 Jan 2026
Copy link to clipboard 
Print this post

I've only used 8 case statements.
what's wrong with if x=1 then whatever else if whatever then whatever :else :end if.
ie if instead of case and when condition met then end if.... or goto end :)
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10844
Posted: 07:24pm 10 Jan 2026
Copy link to clipboard 
Print this post

I'll put a fix for this in 6.02.00
 
Peter63
Senior Member

Joined: 28/07/2017
Location: Sweden
Posts: 116
Posted: 05:54am 11 Jan 2026
Copy link to clipboard 
Print this post

Hello, terekgabor

I made a small change in my test program.
You can enter numbers between 1-64 but not over because then it will be
Error: Not enough memory
If U Run the program, you can see that 64 is OK but 65 is not...

> run
input string? 45
45
input string? 60
60
input string? 64
64
input string? 65
[138] Case "65"
Error : Not enough memory
>

If you know about the limitation or the reason you can still use Select case... in your program.
According to Peter, he will fix this in the next version...
  Quote  I'll put a fix for this in 6.02.00
 

/ Peter63

'
' select case - test program 2
'

Do

Input "input string";s$

Select Case s$
 Case "1"
   Print "1"
 Case "2"
   Print "2"
 Case "3"
   Print "3"
 Case "4"
   Print "4"
 Case "5"
   Print "5"
 Case "6"
   Print "6"
 Case "7"
   Print "7"
 Case "8"
   Print "8"
 Case "9"
   Print "9"
 Case "10"
   Print "10"
 Case "11"
   Print "11"
 Case "12"
   Print "12"
 Case "13"
   Print "13"
 Case "14"
   Print "14"
 Case "15"
   Print "15"
 Case "16"
   Print "16"
 Case "17"
   Print "17"
 Case "18"
   Print "18"
 Case "19"
   Print "19"
 Case "20"
   Print "20"
 Case "21"
   Print "21"
 Case "22"
   Print "22"
 Case "23"
   Print "23"
 Case "24"
   Print "24"
 Case "25"
   Print "25"
 Case "26"
   Print "26"
 Case "27"
   Print "27"
 Case "28"
   Print "28"
 Case "29"
   Print "29"
 Case "30"
   Print "30"
 Case "31"
   Print "31"
 Case "32"
   Print "32"
 Case "33"
   Print "33"
 Case "34"
   Print "34"
 Case "35"
   Print "35"
 Case "36"
   Print "36"
 Case "37"
   Print "37"
 Case "38"
   Print "38"
 Case "39"
   Print "39"
 Case "40"
   Print "40"
 Case "41"
   Print "41"
 Case "42"
   Print "42"
 Case "43"
   Print "43"
 Case "44"
   Print "44"
 Case "45"
   Print "45"
 Case "46"
   Print "46"
 Case "47"
   Print "47"
 Case "48"
   Print "48"
 Case "49"
   Print "49"
 Case "50"
   Print "50"
 Case "51"
   Print "51"
 Case "52"
   Print "52"
 Case "53"
   Print "53"
 Case "54"
   Print "54"
 Case "55"
   Print "55"
 Case "56"
   Print "56"
 Case "57"
   Print "57"
 Case "58"
   Print "58"
 Case "59"
   Print "59"
 Case "60"
   Print "60"
 Case "61"
   Print "61"
 Case "62"
   Print "62"
 Case "63"
   Print "63"
 Case "64"
   Print "64"
 Case "65"
   Print "65"
 Case "66"
   Print "66"
 Case "67"
   Print "67"
 Case "68"
   Print "68"
 Case "69"
   Print "69"
 Case "70"
   Print "70"
 Case "71"
   Print "71"
 Case "72"
   Print "72"
 Case "73"
   Print "73"
 Case "74"
   Print "74"
 Case "75"
   Print "75"
 Case "76"
   Print "76"
 Case "77"
   Print "77"
 Case "78"
   Print "79"
 Case "80"
   Print "80"
 Case "81"
   Print "81"
 Case "82"
   Print "82"
 Case "83"
   Print "83"
 Case "84"
   Print "84"
 Case "85"
   Print "85"
 Case "86"
   Print "86"
 Case "87"
   Print "87"
 Case "88"
   Print "88"
 Case "89"
   Print "89"
 Case "90"
   Print "90"
 Case "91"
   Print "91"
 Case "92"
   Print "92"
 Case "93"
   Print "93"
 Case "94"
   Print "94"
 Case "95"
   Print "95"
 Case "96"
   Print "96"
 Case "97"
   Print "97"
 Case "98"
   Print "98"
 Case "99"
   Print "99"
 Case "100"
   Print "100"
 Case "101"
   Print "101"
 Case "102"
   Print "102"
 Case "103"
   Print "103"
 Case "104"
   Print "104"
 Case "105"
   Print "105"
 Case "106"
   Print "106"
 Case "107"
   Print "107"
 Case "108"
   Print "108"
 Case "109"
   Print "109"
 Case "110"
   Print "110"
 Case "111"
   Print "111"
End Select

Loop


End
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026