b4a 2.70

SoyEli

Active Member
Licensed User
Longtime User
Hello:

I'm getting this under:
Sub Activity_KeyPress (KeyCode As Int) As Boolean

not all code paths return a value (warning #2)


Why?

Thank you:
 

PenguinHero

Member
Licensed User
Longtime User
Hi SoyEli,

I presume that you have some code in that Sub.

Is it possible that you have conditions (if statements) that would prevent a value being returned for the Sub, that you are only returning a value when a certain condition is met?

You can paste the code and let everyone have a look.

And its probably stating the obvious, but it is only a warning. If your code is doing what you want it to, its probably safe to ignore it.
 
Upvote 0

SoyEli

Active Member
Licensed User
Longtime User
Thank you for any help;

Here is the code:

Is working ok, did not show any error on prev b4a., only on upgrade to 2.70

Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then
If MapPanel.Visible=True Then
Main.BringToFront
MapPanel.SendToBack
MapPanel.Visible=False
MapPanel.RemoveAllViews
Return True
End If
If Main.Visible=True Then
HomeScreen
Return True
End If
End If
End Sub
 
Upvote 0

yttrium

Active Member
Licensed User
Longtime User
Please use code tags next time.

Your code should be the following, though I don't know if this is redundant:

B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK Then
      If MapPanel.Visible=True Then
         Main.BringToFront
        MapPanel.SendToBack
        MapPanel.Visible=False
        MapPanel.RemoveAllViews
       Return True
     End If    
     If Main.Visible=True Then
       HomeScreen
        Return True
      End If
   End If
   Return False
End Sub
 
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
You are missing a return value if the KeyCode is not KeyCodes.KEYCODE_BACK
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean
    If KeyCode = KeyCodes.KEYCODE_BACK Then
      If MapPanel.Visible=True Then
         Main.BringToFront
         MapPanel.SendToBack
         MapPanel.Visible=False
         MapPanel.RemoveAllViews
         Return True
      End If     
      If Main.Visible=True Then
         HomeScreen
         Return True
      End If
    End If
    Return False ' You are missing this return value if the IF block above is not entered
End Sub
 
Upvote 0

yttrium

Active Member
Licensed User
Longtime User
Thank you !!!

that worked.

Please explain:
"code tags"

This forum has a special set of BBCode tags when posting that formats your text nicely. For example,

HTML:
[code]Dim Button1 As Button[/code]
displays as
B4X:
Dim Button1 As Button
 
Upvote 0
Top