Android Question Select Case with OR [SOLVED]

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

I am seeking a bit of education in the use of OR/AND in matching strings in the CASE. The code below is a simplified version of the real thing.
Below, the first 3 Cases work. The problem occurs when I use the OR function, I understood that this should work but it does not. I can solve my immediate problem by putting each case on a separate line but the code would be neater if the OR worked.



B4X:
PSUB = Recording(FNum,Step_count,1)  'PSUB is delcared as String in Process Globals
                   
                    Select PSUB
                        Case "Equal_Click"    
                            Step_count = Step_count - 1
                            Idisplay.Text = Idisplay.Text.SubString2(0,Max(0, Idisplay.Text.Length-1))
                           
                        Case "Plus_click"   
                            Step_count = Step_count - 1
                            Idisplay.Text = Idisplay.Text.SubString2(0,Max(0, Idisplay.Text.Length-1))
                           
                        Case "Minus_click" Or "Divide_click" Or "Multiply_Click"  Or "ChangeSign_Click"
                            Step_count = Step_count - 1
                            Idisplay.Text = Idisplay.Text.SubString2(0,Max(0, Idisplay.Text.Length-1))
                           
                        Case "Factorial_click" Or "PI_Click" Or "tLn_Click"
                            Step_count = Step_count - 1
                            Idisplay.Text = Idisplay.Text.SubString2(0,Max(0, Idisplay.Text.Length-2))
                               
                        Case "ANS_Click" Or "mod_click" Or     "Absolute" Or "iLn_Click" Or "tLog_Click" Or "iLog_Click"
                            Step_count = Step_count - 1
                            Idisplay.Text = Idisplay.Text.SubString2(0,Max(0, Idisplay.Text.Length-3))

                        Case "tSin_Click" Or "tCos_Click" Or "tTan_Click" Or "isin_click" Or "icos_click" Or "itan_click"
                            Step_count = Step_count - 1
                            Idisplay.Text = Idisplay.Text.SubString2(0,Max(0, Idisplay.Text.Length-3))
                           
                        Case "btnSinh_click" Or    "btnCosh_click" Or "btnTanh_click"
                            Step_count = Step_count - 1
                            Idisplay.Text = Idisplay.Text.SubString2(0,Max(0, Idisplay.Text.Length-4))
                                                   
                        Case "NEXTFORM"
                            Step_count = Step_count - 1
                            Idisplay.Text = Idisplay.Text.SubString2(0,Max(0, Idisplay.Text.Length-4))
                            Results(FNum,Results_Flag,0) = ""
                            Results_Flag = Results_Flag - 1
                           
                        Case "aSinh" Or    "aCosh" Or "aTanh"
                            Step_count = Step_count - 1
                            Idisplay.Text = Idisplay.Text.SubString2(0,Max(0, Idisplay.Text.Length-5))
                End Select


The log file is below.

B4X:
** Activity (main) Create, isFirst = true **
No wakelock.
** Activity (main) Resume **
** Activity (main) Resume **
An error occurred:
(Line: 766) Select PSUB
java.lang.RuntimeException: Cannot parse: Minus_click as boolean
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **


Any guidance greatfully received.

Regards Roger
 

DonManfred

Expert
Licensed User
Longtime User
Use a IF contruct than a select case.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
have you tried

B4X:
 Case "Minus_click", "Divide_click", "Multiply_Click", "ChangeSign_Click"

Based on the documentation it should work

Hi DonManfred,

You've done it again. Comma's instead of the Logic Or works. I thought that I did see code example using Or when trolling the forum, it appears I was wrong.
Thanks again.

Regards Roger
 
Upvote 0
Top