Android Question Select Case Missing Parameter error and syntax error

Tim Chapman

Active Member
Licensed User
Longtime User
Hello,

I am getting Missing Parameter on line 3 and
Syntax error on line 4

I have tried every combination of parenthesis and putting the variable name in the case statements. No joy.

Any ideas?

Code Sample:
Sub BehaviorCheck
    Private D As Byte
    Select Case D
        Case < 6 'Passive
            ActionTable2Modifier = ActionTable2Modifier - 2
        Case < 11 'Moderate
            'ActionTable2Modifier does Not change.
        Case < 16 'Active
            ActionTable2Modifier = ActionTable2Modifier + 2
        Case  > 15 'Agressive
            ActionTable2Modifier = ActionTable2Modifier + 4
    End Select
End Sub
 

TILogistic

Expert
Licensed User
Longtime User
B4X:
    Private D As Byte
    Select True
        Case D < 6 'Passive
'            ActionTable2Modifier = ActionTable2Modifier - 2
        Case D < 11 'Moderate
'            'ActionTable2Modifier does Not change.
        Case D < 16 'Active
'            ActionTable2Modifier = ActionTable2Modifier + 2
        Case D > 15 'Agressive
'            ActionTable2Modifier = ActionTable2Modifier + 4
        Case Else
    End Select
 
Upvote 0

Tim Chapman

Active Member
Licensed User
Longtime User
Is there some reason why the language doesn't support "normal" select case statements? Can this be fixed?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
B4X:
Select D
      ...

not
B4X:
Select Case D
     ...
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
B4X:
Select D
      ...

not
B4X:
Select Case D
     ...
This doesn't fix the code.
Select Case is also acceptable while it is optional (mentioned in B4X Booklet) and it will be ignored.

One thing I suggest from the answer in post #2 is the last condition check (Case Else) and passing the value as parameter in function signature.

B4X:
Sub BehaviorCheck (D As Byte)
    Select True
        Case D < 6
            Log("Passive")
        Case D < 11
            Log("Moderate")
        Case D < 16
            Log("Active")
        Case Else ' D > 15
            Log("Agressive")
    End Select
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…