B4R Question Question about Select Case

daveinhull

Member
Licensed User
Hi,

The case statement below doesn't get executed when Action contains "a". Processing action a gets logged, but then nothing for the actual case for "a".
Have I got something wrong here?

B4X:
    Private FST() As Byte = Array As Byte (4,2,0,0,0,0,5,3,1,0,0,0,6,0,2,0,0,0,0,0,0,0,1,1,0,0,0,0,6,0,0,0,0,01,0)
    Private FST_A() As Byte = "ea    faa   g a      dcb    g     b "
    Private FST_State As Byte
...
...
Sub FST_Process (Event As Byte)
Dim NewState As Byte
Dim Action As Byte
    Log ("Current state = ", FST_State," Event = ", Event)
    NewState = FST((FST_State-1)*6+Event-1)
    Action = FST_A((FST_State-1)*6+Event-1)
    Log ("NewState = ", NewState, " Action = ", Array As Byte(Action))
    If NewState <> 0 Then
        FST_State = NewState   
    End If
    If Action <> " " Then
        Log ("Processing action ",Array As Byte(Action))
        Select Case Action
            Case "a"
                Log ("Cursor = ", MyCursor)
                If Event = 2 Then
                    MyCursor = MyCursor + 1
                Else
                    MyCursor = MyCursor - 1
                End If
                Log ("Cursor = ", MyCursor)
                Cursor(MyCursor)
            Case "b"
            Case "c"
            Case "d"
            Case "e"
            Case "f"
            Case "g"
        End Select
    End If
End Sub
 

daveinhull

Member
Licensed User
Thank both.

I use letters simply for readability as I could set up the action list as in the state transfer list.
I guess I could use the byte converter and sub strings etc to get an action letter, but would it be wroth it?

Dave

[EDIT: Sorry I replied before seeing NoNickName reply]
 
Upvote 0

NoNickName

Member
Licensed User
As long as the problem is solved, it is always worth it. Maybe later in the dev process you can think of something better and more efficient.
 
Upvote 0
Top