Android Question Class SlidingSidebar warning

Addo

Well-Known Member
Licensed User
Longtime User
i am trying to use Class Slidingsidebar but the module gives this warning in the log

Not all code paths Return value

at this code

B4X:
Private Sub CalcDistance(FromOpen As Boolean) As Int
    ' Calculates the distance between the current position and the position to reach
    Select sbPosition
        Case 0 'LEFT
            If sbAnimType = 2 Then
                If FromOpen Then
                    Return - pnlSidebar.Left
                Else
                    Return - pnlSidebar.Left - pnlSidebar.Width
                End If
            Else
                If FromOpen Then
                    Return pnlSidebar.Width - pnlContent.Left
                Else
                    Return - pnlContent.Left
                End If
            End If
        Case 1 'RIGHT
            If sbAnimType = 2 Then
                If FromOpen Then
                    Return - pnlSidebar.Left + pnlContent.Width - pnlSidebar.Width
                Else
                    Return - pnlSidebar.Left + pnlContent.Width
                End If
            Else
                If FromOpen Then
                    Return - pnlSidebar.Width - pnlContent.Left
                Else
                    Return - pnlContent.Left
                End If
            End If
        Case 2 'TOP
            If sbAnimType = 2 Then
                If FromOpen Then
                    Return - pnlSidebar.Top
                Else
                    Return - pnlSidebar.Top - pnlSidebar.Height
                End If
            Else
                If FromOpen Then
                    Return pnlSidebar.Height - pnlContent.Top
                Else
                    Return - pnlContent.Top
                End If
            End If
        Case 3 'BOTTOM
            If sbAnimType = 2 Then
                If FromOpen Then
                    Return - pnlSidebar.Top + pnlContent.Height - pnlSidebar.Height
                Else
                    Return - pnlSidebar.Top + pnlContent.Height
                End If
            Else
                If FromOpen Then
                    Return - pnlSidebar.Height - pnlContent.Top
                Else
                    Return - pnlContent.Top
                End If
            End If
    End Select
End Sub

why this warning raised ?
 

clarionero

Active Member
Licensed User
Longtime User
i am trying to use Class Slidingsidebar but the module gives this warning in the log



at this code

B4X:
Private Sub CalcDistance(FromOpen As Boolean) As Int
    ' Calculates the distance between the current position and the position to reach
    Select sbPosition
        Case 0 'LEFT
            If sbAnimType = 2 Then
                If FromOpen Then
                    Return - pnlSidebar.Left
                Else
                    Return - pnlSidebar.Left - pnlSidebar.Width
                End If
            Else
                If FromOpen Then
                    Return pnlSidebar.Width - pnlContent.Left
                Else
                    Return - pnlContent.Left
                End If
            End If
        Case 1 'RIGHT
            If sbAnimType = 2 Then
                If FromOpen Then
                    Return - pnlSidebar.Left + pnlContent.Width - pnlSidebar.Width
                Else
                    Return - pnlSidebar.Left + pnlContent.Width
                End If
            Else
                If FromOpen Then
                    Return - pnlSidebar.Width - pnlContent.Left
                Else
                    Return - pnlContent.Left
                End If
            End If
        Case 2 'TOP
            If sbAnimType = 2 Then
                If FromOpen Then
                    Return - pnlSidebar.Top
                Else
                    Return - pnlSidebar.Top - pnlSidebar.Height
                End If
            Else
                If FromOpen Then
                    Return pnlSidebar.Height - pnlContent.Top
                Else
                    Return - pnlContent.Top
                End If
            End If
        Case 3 'BOTTOM
            If sbAnimType = 2 Then
                If FromOpen Then
                    Return - pnlSidebar.Top + pnlContent.Height - pnlSidebar.Height
                Else
                    Return - pnlSidebar.Top + pnlContent.Height
                End If
            Else
                If FromOpen Then
                    Return - pnlSidebar.Height - pnlContent.Top
                Else
                    Return - pnlContent.Top
                End If
            End If
    End Select
End Sub

why this warning raised ?

What happens if spPosition is not 0,1,2,3? In that case what value is returned?
You have yet to contemplate that case.

Rubén
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Maybe because not all your returning values are INTegers!?
Change the declaration of the SUB to Double or Long

from
B4X:
Private Sub CalcDistance(FromOpen As Boolean) As Int
to
B4X:
Private Sub CalcDistance(FromOpen As Boolean) As Double
 
Upvote 0
Top