Please see this thread: https://www.b4x.com/android/forum/threads/select-case-in-b4r.106120/
Failures if more that 10 select cases in the code
Failures if more that 10 select cases in the code
It is not a bug with the compiler. I just made as simple 20-level test inside a for/next loop and it worked correctly. It must be something you're doing in your case statements.Please see this thread: https://www.b4x.com/android/forum/threads/select-case-in-b4r.106120/
Failures if more that 10 select cases in the code
Select Case 1
Case 1
Log("1st case 1")
Case 1
Log("2nd case 1")
Case 1
Log("3rd case 1")
End Select
No, it works, didn't know it.Will using 'Select Case something' cause any problems?
????Very funnyI've tried:
and it logs only "1st case 1" as I would expect.B4X:Select Case 1 Case 1 Log("1st case 1") Case 1 Log("2nd case 1") Case 1 Log("3rd case 1") End Select
Very simple, just a for/next loop with 20 cases:could you show the code?
Dim piIndex As Int
Log("Start of 20 loop")
For piIndex = 1 To 20
Select Case piIndex
Case 1
Log("Case is 1")
Case 2
Log("Case is 2")
Case 3
Log("Case is 3")
Case 4
Log("Case is 4")
Case 5
Log("Case is 5")
Case 6
Log("Case is 6")
Case 7
Log("Case is 7")
Case 8
Log("Case is 8")
Case 9
Log("Case is 9")
Case 10
Log("Case is 10")
Case 11
Log("Case is 11")
Case 12
Log("Case is 12")
Case 13
Log("Case is 13")
Case 14
Log("Case is 14")
Case 15
Log("Case is 15")
Case 16
Log("Case is 16")
Case 17
Log("Case is 17")
Case 18
Log("Case is 18")
Case 19
Log("Case is 19")
Case 20
Log("Case is 20")
End Select
Next
sub1
dim index1 as int = 1
select index
case 1
'do something
case 2
'do something
case 3
'do something
end select
end sub
sub2
dim index2 as int = 2
select index2
Case 1
'do something
Case 2
'do something
Case 3
'do something
end select
end sub
'repeated to a total of eleven times will cause failures somewhere, maybe not in one of these subs
'if there are 10 or less 'selects' then it will be OK
Private Sub GetFontByte(Number As Int, Index As UInt) As Byte
Select Case Number
Case 0
Return RunNative("getAdz1", Index)
Case 1
Return RunNative("getAdz2", Index)
Case 2
Return RunNative("getAdz3", Index)
Case Else
Return RunNative("getAdz1", Index)
End Select
End Sub
Private Sub GetFontByte(Number As Int, Index As UInt) As Byte
If Number = 0 Then
Return RunNative("getAdz1", Index)
else if Number = 1 Then
Return RunNative("getAdz2", Index)
else if Number = 2 Then
Return RunNative("getAdz3", Index)
Else
Return RunNative("getAdz1", Index)
End If
End Sub
I'm sorry but you shouldn't post in old threads. Such posts are ignored.Please see this thread: https://www.b4x.com/android/forum/threads/select-case-in-b4r.106120/
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 1500
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
' Sub1
' sub2
' Sub3
' sub4
' Sub5
' sub6
' Sub7
' sub8
' Sub9
' sub10
' Sub11
' sub12
Dim x() As Byte = "abcd"
Anothersub(1, 2, 3, x)
Log("RAM3: ", AvailableRAM)
Log("Stack3: ", StackBufferUsage)
End Sub
Sub Anothersub(x As Int, y As Int, z As Int, Text() As Byte)
Log("RAM1: ", AvailableRAM)
Log("Stack1: ", StackBufferUsage)
Log("Another sub")
Log(Text)
Log("RAM2: ", AvailableRAM)
Log("Stack2: ", StackBufferUsage)
End Sub
'Sub Sub1
' Log("Sub 1")
' Dim index1 As Int = 1
'
'Select index1
' Case 1
' 'do something
' Case 2
' 'do something
' Case 3
' 'do something
' End Select
'End Sub
'Sub sub2
' Log("Sub 2")
' Dim index2 As Int = 2
'
' Select index2
' Case 1
' 'do something
' Case 2
' 'do something
' Case 3
' 'do something
' End Select
'End Sub
'
'Sub Sub3
' Log("Sub 3")
' Dim index1 As Int = 1
'
'Select index1
' Case 1
' 'do something
' Case 2
' 'do something
' Case 3
' 'do something
' End Select
'End Sub
'Sub sub4
' Log("Sub 4")
' Dim index2 As Int = 2
'
' Select index2
' Case 1
' 'do something
' Case 2
' 'do something
' Case 3
' 'do something
' End Select
'End Sub
'
'Sub Sub5
' Log("Sub 5")
' Dim index1 As Int = 1
'
'Select index1
' Case 1
' 'do something
' Case 2
' 'do something
' Case 3
' 'do something
' End Select
'End Sub
'
'Sub sub6
' Log("Sub 6")
' Dim index2 As Int = 2
'
' Select index2
' Case 1
' 'do something
' Case 2
' 'do something
' Case 3
' 'do something
' End Select
'End Sub
'
'Sub Sub7
' Log("Sub7")
' Dim index1 As Int = 1
'
'Select index1
' Case 1
' 'do something
' Case 2
' 'do something
' Case 3
' 'do something
' End Select
'End Sub
'Sub sub8
' Log("Sub8")
' Dim index2 As Int = 2
'
' Select index2
' Case 1
' 'do something
' Case 2
' 'do something
' Case 3
' 'do something
' End Select
'End Sub
'Sub Sub9
' Log("Sub9")
' Dim index1 As Int = 1
'
'Select index1
' Case 1
' 'do something
' Case 2
' 'do something
' Case 3
' 'do something
' End Select
'End Sub
'Sub sub10
' Log("Sub10")
' Dim index2 As Int = 2
'
' Select index2
' Case 1
' 'do something
' Case 2
' 'do something
' Case 3
' 'do something
' End Select
'End Sub
'Sub Sub11
' Log("Sub11")
' Dim index1 As Int = 1
'
' Select index1
' Case 1
' 'do something
' Case 2
' 'do something
' Case 3
' 'do something
' End Select
'End Sub
'
'Sub sub12
' Log("Sub12")
' Dim index2 As Int = 2
'
' Select index2
' Case 1
' 'do something
' Case 2
' 'do something
' Case 3
' 'do something
' End Select
'End Sub
.......
Sketch uses 6168 bytes (19%) of program storage space. Maximum is 32256 bytes.
Global variables use 281 bytes (13%) of dynamic memory, leaving 1767 bytes for local variables. Maximum is 2048 bytes.
Uploading...
********************* PROGRAM STARTING ****************
AppStart
2986344448020480-1023035899095813632-805306368474624-3019898880071680036074291201125268492608358439375939379300.00000.0000
Stack1: 4
Another sub
RAM2: 1719
Stack2: 4
RAM3: 1714
Stack3: 4
.........
Sketch uses 5452 bytes (16%) of program storage space. Maximum is 32256 bytes.
Global variables use 281 bytes (13%) of dynamic memory, leaving 1767 bytes for local variables. Maximum is 2048 bytes.
Uploading...
********************* PROGRAM STARTING ****************
AppStart
An
AppStart
ovf020480212802550071680034853393734047007694��x�V��V��Z���(e^)�u �a�T��_u�ʑ�^>�>o�w���mM"28366���/�;R<����~"�u���r�x7���5�v�x6g?�z��iu������>KS�Qz�x�����k��x�V��V��Z���(e^)�u �a�T��_u�ʑ�^>�>o�w���mM�