Calling a Public Sub in a class from another class:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
This is the code in the other class being called:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
It compiles fine, but get this error:
cvmap_touchinshape (java line: 1764)
java.lang.Exception: Sub pointinshapex was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:219)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1082)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1037)
at b4a.sqlitelight1.cvmap._touchinshape(cvmap.java:1764)
at b4a.sqlitelight1.cvmap._fviewtouch_touch(cvmap.java:813)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA$1.run(BA.java:352)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8633)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)
When I call another Sub in the same class that has Public Sub PointInShapeX it all runs fine.
That other Sub is very similar and this is the code of that Sub:
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Can't understand this at all.
Any ideas?
RBS
			
			
			
				B4X:
			
		
		
		private Sub touchInShape(aX As Double, aY As Double) As Map
    
    Dim m As Map
    Dim p As TMapPoint = MapUtilities.initPoint(aX, aY)
    Dim tLL As TMapLatLng = PointToLatLng(p)
    m.Initialize
    For Each oKey As Object In fMap.fShapes.Keys
        Dim oItem As Object = fMap.fShapes.Get(oKey)
        If CallSub2(oItem, "PointInShapeX", tLL) Then '<<<<<<<<< error Sub not found here
        'If CallSub2(oItem,"PointInShape", p) Then
            m.Put(oKey, oItem)
        End If
    Next
    Return m
End Sub
	This is the code in the other class being called:
			
				B4X:
			
		
		
		'return true if type LatLng is in shape
Public Sub PointInShapeX(tLL As TMapLatLng) As Boolean
    
    'to do a quick and simple check first
    Dim BB As TMapBoxLatLng = BoundingBox2(fShape)
    If (tLL.fLat > BB.fLeftTop.fLat) Or (tLL.fLat < BB.fRightBottom.fLat) Or _
        (tLL.fLng > BB.fRightBottom.fLng) Or (tLL.fLng < BB.fLeftTop.fLng) Then
        Return False
    End If
    
'    'http://geomalgorithms.com/a03-_inclusion.html
'    '2012 Dan Sunday
'    '---------------------------------------------
    Dim i As Int
    Dim wn As Int
    Dim iUBound As Int
    Dim tLL1 As TMapLatLng
    Dim tLL2 As TMapLatLng
    
    iUBound = fShape.fLatLng.Size - 1
    For i = 0 To iUBound - 1 '- 1 as we do i + 1
        tLL1 = fShape.fLatLng.Get(i)
        tLL2 = fShape.fLatLng.Get(i + 1)
        If tLL1.flng <= tLL.fLng Then
            If tLL2.flng > tLL.fLng Then
                If IsLeft(tLL1, tLL2, tLL.fLat, tLL.fLng) Then
                    wn = wn + 1
                End If
            End If
        Else
            If tLL2.flng <= tLL.fLng Then
                If IsLeft(tLL1, tLL2, tLL.fLat, tLL.fLng) = False Then
                    wn = wn - 1
                End If
            End If
        End If
    Next
    
    Return wn <> 0
    
End Sub
	It compiles fine, but get this error:
cvmap_touchinshape (java line: 1764)
java.lang.Exception: Sub pointinshapex was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:219)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1082)
at anywheresoftware.b4a.keywords.Common.CallSubNew2(Common.java:1037)
at b4a.sqlitelight1.cvmap._touchinshape(cvmap.java:1764)
at b4a.sqlitelight1.cvmap._fviewtouch_touch(cvmap.java:813)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.BA$1.run(BA.java:352)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8633)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1133)
When I call another Sub in the same class that has Public Sub PointInShapeX it all runs fine.
That other Sub is very similar and this is the code of that Sub:
			
				B4X:
			
		
		
		'return true if point is in shape
Public Sub PointInShape(aPoint As TMapPoint) As Boolean
    
    'https://wrf.ecse.rpi.edu/Research/Short_Notes/pnpoly.html
    
    'to do a quick and simple check first
    Dim r As B4XRect = BoundingBox(fShape)
    If (aPoint.fX < r.left) Or (aPoint.fX > r.Right) Or (aPoint.fY < r.Top) Or (aPoint.fY > r.Bottom) Then
        Return False
    End If
    Dim bInside As Boolean
    Dim i As Int
    Dim j As Int = fShape.fLatLng.size - 1
    
    For i = 0 To fShape.fLatLng.Size - 1
        Dim pti As TMapPoint = fcvMap.LatLngToPoint(fShape.fLatLng.Get(i))
        Dim ptj As TMapPoint = fcvMap.LatLngToPoint(fShape.fLatLng.Get(j))
        If ((pti.fy > aPoint.fY) <> (ptj.fy > aPoint.fY)) And _
            (aPoint.fX < (ptj.fX - pti.fX) * (aPoint.fY - pti.fY) / (ptj.fy - pti.fY) + pti.fX) Then
            bInside = Not(bInside)
        End If
        j = i
    Next
    
    Return bInside
    
End Sub
	Can't understand this at all.
Any ideas?
RBS