Android Question map bug or I am missing something [sorted]

Terence Agius

Member
Licensed User
I have this code

B4X:
Sub Process_Globals
    Type stService ( id As Int, bDeleted As Boolean, bEnabled As Boolean, name As String, address As String, port As Int,  username As String,  password As String, find As String, cType As String, delay As Int )
    
end sub

Sub LoadSettings
    Private        map As stService


                For i = 0 To mapCheckList.Size - 1
            map = mapCheckList.GetValueAt(i)
            
            Log( map )   'shows ok
            
            If map.bDeleted = False Then
        
                        end if
      next
end sub

I get this

Added -->to st
Timer1 - 8
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
[IsInitialized=false, address=192.168.10.15, bDeleted=false
, bEnabled=false, cType=http, delay=0
, find=mdaemon, id=0, name=to st
, password=null, port=90, username=null
]
Error occurred on line: 636 (Main)
java.lang.RuntimeException: Field: bDeleted not found in: java.lang.String
at anywheresoftware.b4a.shell.Shell$FieldCache.getField(Shell.java:908)
at anywheresoftware.b4a.shell.Shell.getField(Shell.java:678)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:259)
at b4a.checkserver.main._loadsettings(main.java:699)
at b4a.checkserver.main._activity_create(main.java:480)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
at b4a.checkserver.main.afterFirstLayout(main.java:102)
at b4a.checkserver.main.access$000(main.java:17)
at b4a.checkserver.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)



Any ideas?
 

DonManfred

Expert
Licensed User
Longtime User
Try to reproduce it in a small project and upload the project.

From the snipped you posted it is hard to give any congrete Advice.

Check the type of
B4X:
 mapCheckList.GetValueAt(i)

Add this to your loop...
B4X:
log(GetType(mapCheckList.GetValueAt(i))
 
Upvote 0

Terence Agius

Member
Licensed User
B4X:
#Region  Project Attributes
    #ApplicationLabel: Test map
    #VersionCode: 1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    Type stService ( id As Int, bDeleted As Boolean, bEnabled As Boolean, name As String, address As String, port As Int,  username As String,  password As String, find As String, cType As String, delay As Int )
    
    szINIFile     = "testmap.conf"

End Sub

Sub Globals
    
    Private        mapConfig As Map
    
End Sub

Sub Activity_Create(FirstTime As Boolean)

    Private        map As stService
    Private     map2 As stService

    If File.ExternalWritable = False Then
        Msgbox("Cannot write on storage card.", "")
        Log( "Write error" )
        Return
    End If
    
    map2.name = "Test"
    map2.find = "find"
    map2.bEnabled = True
    map2.bDeleted = False
    map2.address = "192.168.0.9"
    
    mapConfig.Initialize
    mapConfig.Put( map2.name, map2 )
    File.WriteMap( File.DirRootExternal,szINIFile, mapConfig)
    Sleep( 1000 )
    
    Msgbox( "Written", "Debug" )
    
    If File.Exists(File.DirRootExternal,szINIFile) = True Then
        
        'Msgbox( "Reading map", "Debug" )
        mapConfig = File.ReadMap(File.DirRootExternal,szINIFile)
    
        For i = 0 To mapConfig.Size - 1
            map = mapConfig.GetValueAt(i)
            
            Msgbox( map, "Debug" )
            
            If map.bDeleted = False Then
                Log( "Skip " & i )
            End If
        Next
    End If
        
End Sub


this program reproduces the issue
 
Upvote 0
Top