I seem to be having problems reading a list that I just saved using custom type.
This is what the list looks like in a "Unix-aware" text editor (TextPad):
The data I feed it should not include any carriage return even though it is possible that the Name parameter has one. For sure, the Col parameter does not include one since it is declared as an Int yet the map file showing in the text editor shows line breaks after each Col = xx parameter.
Here is the error log for the line that causes the crash:
So the Name parameter is actually terminated with 0x0A which is unexpected but maybe explainable because it came from a file in MSDOS format (0x0D, 0x0A) but even more strange is that the Col parameter is also followed with 0x0A even though it is defined as an Int, not a String.
I must be missing something...
Anyhow, I wanted to save the list and retrieve it as-is to save time, I am surprised that I have errors reading a list I just saved.
This is under Windows 10 64 bits using OpenJDK-11.0.1
TIA
B4X:
Type ItemType( Ndx As Int, Name As String, Addr As Int, lstBits As List, lstTlms As List, ... )
Dim item as ItemType
item.Initialize
Dim lst as List
lst.Initialize
' store strings, lists and numbers in Item
item.Ndx = 0 ' <- a number
item.Name = "abcd" ' Note: Name is read from an MSDOS formatted file and may include the CRLF
item.Addr = 2 ' <- a number
...
' add Item to the list
lst.Add( Item )
' save to disk
File.WriteList( dir, file, lst )
' sometime later
Dim lst as list
lst = File.ReadList( dir, file )
Log( item.Addr ) <= crashes on that statement: "Error evaluating expression."
It looks like there are a number of line breaks that "break" the ReadList function.[IsInitialized=true, Ndx=0, Name=PS0
, Addr=1, lstBits=(ArrayList) [[IsInitialized=true, Row=3, Col=17
, Description=, MsgTrue= Run, MsgFalse=Ready
, colorTrue=false, colorFalse=false, ByteNum=1
, OrMask=1, AndMask=1, Fault=false
], [IsInitialized=true, Row=3, Col=25
, Description=, MsgTrue= Run, MsgFalse=Ready
, colorTrue=false, colorFalse=false, ByteNum=3
, OrMask=4, AndMask=4, Fault=false
], [IsInitialized=true, Row=3, Col=54
, Description=, MsgTrue=Flt, MsgFalse= Ok
, colorTrue=true, colorFalse=false, ByteNum=2
, OrMask=32, AndMask=32, Fault=false
], [IsInitialized=true, Row=3, Col=58
, Description=, MsgTrue=Flt, MsgFalse= Ok
, colorTrue=true, colorFalse=false, ByteNum=3
, OrMask=16, AndMask=16, Fault=false
], [IsInitialized=true, Row=3, Col=62
, Description=, MsgTrue=Flt, MsgFalse= Ok
, colorTrue=true, colorFalse=false, ByteNum=2
, OrMask=16, AndMask=16, Fault=false
], [IsInitialized=true, Row=3, Col=66
, Description=, MsgTrue=Flt, MsgFalse= Ok
, colorTrue=true, colorFalse=false, ByteNum=1
, OrMask=2, AndMask=2, Fault=false
], [IsInitialized=true, Row=3, Col=71
, Description=, MsgTrue=Mnt, MsgFalse=Usr
, colorTrue=true, colorFalse=false, ByteNum=2
, OrMask=8, AndMask=8, Fault=false
]], lstTlms=(ArrayList) [[IsInitialized=true, Row=3, Col=9
, Description=, Format=#####, Cmd=I
, Logging=false], [IsInitialized=true, Row=3, Col=32
, Description=, Format=#####, Cmd=6
, Logging=false], [IsInitialized=true, Row=3, Col=37
, Description=, Format=#####, Cmd=7
, Logging=false], [IsInitialized=true, Row=3, Col=47
, Description=, Format=#####, Cmd=>
, Logging=false]]
, tmoOnStatus=false, DeviceID= Device 0]
The data I feed it should not include any carriage return even though it is possible that the Name parameter has one. For sure, the Col parameter does not include one since it is declared as an Int yet the map file showing in the text editor shows line breaks after each Col = xx parameter.
Here is the error log for the line that causes the crash:
I put the file into a binary viewer and got this:Error occurred on line: 2320
java.lang.RuntimeException: Field: Addr not found in: java.lang.String
at anywheresoftware.b4a.shell.Shell$FieldCache.getField(Shell.java:832)
at anywheresoftware.b4a.shell.Shell.getField(Shell.java:596)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:246)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:64)
at b4j.r9_b4j.main._addressmapget(main.java:340)
at b4j.r9_b4j.main$ResumableSub_mControlScreen_Action.resume(main.java:7466)
at b4j.r9_b4j.main._mcontrolscreen_action(main.java:7348)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
B4X:
0000-0010: 5b 49 73 49-6e 69 74 69-61 6c 69 7a-65 64 3d 74 [IsIniti alized=t
0000-0020: 72 75 65 2c-20 4e 64 78-3d 30 2c 20-4e 61 6d 65 rue,.Ndx =0,.Name
0000-0030: 3d 50 53 30-0a 2c 20 41-64 64 72 3d-31 2c 20 6c =PS0.,.A ddr=1,.l
0000-0040: 73 74 42 69-74 73 3d 28-41 72 72 61-79 4c 69 73 stBits=( ArrayLis
0000-0050: 74 29 20 5b-5b 49 73 49-6e 69 74 69-61 6c 69 7a t).[[IsI nitializ
0000-0060: 65 64 3d 74-72 75 65 2c-20 52 6f 77-3d 33 2c 20 ed=true, .Row=3,.
0000-0070: 43 6f 6c 3d-31 37 0a 2c-20 44 65 73-63 72 69 70 Col=17., .Descrip
0000-0080: 74 69 6f 6e-3d 2c 20 4d-73 67 54 72-75 65 3d 20 tion=,.M sgTrue=.
I must be missing something...
Anyhow, I wanted to save the list and retrieve it as-is to save time, I am surprised that I have errors reading a list I just saved.
This is under Windows 10 64 bits using OpenJDK-11.0.1
TIA