I found a compiler bug that is driving me nutso. I do not know if it is related to B4J, or ABMaterial so I posted under both tags.
Its debilitating because I have to write a super huge select case statement. Otherwise it doesn't work unless its in Debug mode.
Here is a working subroutine:
That code works fine. However, noticed I commented out the "cmdhomeup" function. I figured it would get picked up by the Case Else, and then forward cmdhomeup through the CallSub function. You think it would work, right? Well....
However, I said, why not shorten it to just this:
This way, all strings that contain the ObjectID just gets forwarded to the appropriate function in the EngineShared code module. This way I dont have to write a huge select case statement for each and every function.
This introduces a bug. All the subroutines in the EngineShared module go into purple squigly iines saying cmdhomeup is not used, or such and such is not used.
So, in Release mode. NONE of my "Case Else" subroutines will fire. If I run in Debug mode, it all works fine!
Why??
Its debilitating because I have to write a super huge select case statement. Otherwise it doesn't work unless its in Debug mode.
Here is a working subroutine:
B4X:
Sub myCanvas_ObjectDown(objectID As String)
If Buttonpressed = True Then Return
Buttonpressed = True
Dim myCanvas As ABMCanvas = page.Component("myCanvas")
Select Case objectID
Case "mnupower"
If EngineMS05.Connected = False Then
page.Pause
CallSub2(EngineMS05, "Connect", Me)
Else
CallSub(EngineMS05, "Disconnect")
End If
Case "mnucleargame"
page.Msgbox2("ConfirmClearGame","Are you sure you wish to clear the game?","Clear Game","YES","NO",False,ABM.MSGBOX_TYPE_QUESTION,False,ABM.MSGBOX_POS_CENTER_CENTER,"")
Case "mnusetclock"
If EngineShared.ClockStopped = True Then SetClock
Case "mnutimeofday"
' Case "cmdhomeup"
' CallSub(EngineShared,"cmdHomeUp")
Case "cmdhomedown"
CallSub(EngineShared,"cmdHomeDown")
Case "cmdguestup"
CallSub(EngineShared,"cmdGuestUp")
Case "cmdguestdown"
CallSub(EngineShared,"cmdGuestDown")
Case "cmdstartstopclock"
CallSub2(EngineShared,"cmdStartStopClock",Me)
Case "cmdperiodup"
CallSub(EngineShared,"cmdPeriodUp")
Case "cmdperioddown"
CallSub(EngineShared,"cmdPeriodDown")
End Select
Sleep(150)
Buttonpressed = False
myCanvas.Refresh
'Log("ObjectD: " & objectID)
End Sub
That code works fine. However, noticed I commented out the "cmdhomeup" function. I figured it would get picked up by the Case Else, and then forward cmdhomeup through the CallSub function. You think it would work, right? Well....
However, I said, why not shorten it to just this:
B4X:
Sub myCanvas_ObjectDown(objectID As String)
If Buttonpressed = True Then Return
Buttonpressed = True
Dim myCanvas As ABMCanvas = page.Component("myCanvas")
Select Case objectID
Case "mnupower"
If EngineMS05.Connected = False Then
page.Pause
CallSub2(EngineMS05, "Connect", Me)
Else
CallSub(EngineMS05, "Disconnect")
End If
Case "mnucleargame"
page.Msgbox2("ConfirmClearGame","Are you sure you wish to clear the game?","Clear Game","YES","NO",False,ABM.MSGBOX_TYPE_QUESTION,False,ABM.MSGBOX_POS_CENTER_CENTER,"")
Case "mnusetclock"
If EngineShared.ClockStopped = True Then SetClock
Case "mnutimeofday"
Case "cmdstartstopclock"
CallSub2(EngineShared,"cmdStartStopClock",Me)
Case "cmdsetyards"
SetYards
Case Else
Log("hi")
CallSub(EngineShared,objectID)
End Select
Sleep(150)
Buttonpressed = False
myCanvas.Refresh
' Log("Object: " & objectID)
End Sub
This way, all strings that contain the ObjectID just gets forwarded to the appropriate function in the EngineShared code module. This way I dont have to write a huge select case statement for each and every function.
This introduces a bug. All the subroutines in the EngineShared module go into purple squigly iines saying cmdhomeup is not used, or such and such is not used.
So, in Release mode. NONE of my "Case Else" subroutines will fire. If I run in Debug mode, it all works fine!
Why??