I am trying to create an array of structures (types) and then save them to a list. I then want to write the list to a file using File.WriteList(). These appears to work but when I try to read the list back in, I an getting an exception. I believe the problem is casting but I have tried several solutions but none successful.
The structure is defined in Process_Globals as:
Type RVStruct(Name As String, Length As Int, Width As Int)
Here is the code snippet. The first section created the file. The second reads it. Any assistance would be appreciated
If File.Exists(File.DirDefaultExternal, "ModelsList.txt") = False Then
Dim RVModels As List
RVModels.Initialize
Dim RVM(3) As RVStruct
RVM(0).Initialize
RVM(0).Name = "ModA"
RVM(0).Length = 185
RVM(0).Width = 96
RVM(1).Initialize
RVM(1).Name = "ModB"
RVM(1).Length = 225
RVM(1).Width = 95
RVM(2).Initialize
RVM(2).Name = "ModC"
RVM(2).Length = 250
RVM(2).Width = 94
RVModels.AddAll(RVM)
File.WriteList(File.DirDefaultExternal, "ModelsList.txt", RVModels)
Else
Dim RVModels As List
Dim XM As RVStruct
RVModels.Initialize
XM.Initialize
RVModels = File.ReadList(File.DirDefaultExternal, "ModelsList.txt")
XM = RVModels.Get(0)
Log("Name = " & XM.Name)
Log("Length = " & XM.Length)
Log("Width = " & XM.Width)
End If
The structure is defined in Process_Globals as:
Type RVStruct(Name As String, Length As Int, Width As Int)
Here is the code snippet. The first section created the file. The second reads it. Any assistance would be appreciated
If File.Exists(File.DirDefaultExternal, "ModelsList.txt") = False Then
Dim RVModels As List
RVModels.Initialize
Dim RVM(3) As RVStruct
RVM(0).Initialize
RVM(0).Name = "ModA"
RVM(0).Length = 185
RVM(0).Width = 96
RVM(1).Initialize
RVM(1).Name = "ModB"
RVM(1).Length = 225
RVM(1).Width = 95
RVM(2).Initialize
RVM(2).Name = "ModC"
RVM(2).Length = 250
RVM(2).Width = 94
RVModels.AddAll(RVM)
File.WriteList(File.DirDefaultExternal, "ModelsList.txt", RVModels)
Else
Dim RVModels As List
Dim XM As RVStruct
RVModels.Initialize
XM.Initialize
RVModels = File.ReadList(File.DirDefaultExternal, "ModelsList.txt")
XM = RVModels.Get(0)
Log("Name = " & XM.Name)
Log("Length = " & XM.Length)
Log("Width = " & XM.Width)
End If