-
I know this sounds kinda boring, but.... In you're opinion, what is the best way to read/write?
I'm using:
Code:
Sub LoadFile(sFileName as String)
Dim Temp as String
Open App.Path & "\vector\" & sFileName For Input As #1
Input #1, Temp
Close #1
End Sub
Anyway, you get the Idea. So, how would I maximize my code If I wanted to Read/Write the Data From a User-Defined Type?
This is what it's probably going to be:
Code:
Option Explicit
Public Enum vgfNodeType
vgfLine = 0
vgfPolyLine = 1
vgfFilledPoly = 2
vgfInline = 3
End Enum
Public Type RGBInfo
R As Single
G As Single
B As Single
End Type
Public Type Node
NodeType as vgfNodeType
FilledColour As RGBInfo
LineColour As RGBInfo
LineStart() As POINTAPI
LineEnd() As POINTAPI
AntiAliased As Boolean
End Type
(by the way, I have POINTAPI defined as well)
So, my question is, what would be the best method for writing and reading the Node UDT?
-
If you open in binary, it's quite easy to store UDT's, but if you have dynamic arrays you should store the size of them too:
Code:
Dim n As Node, LS As Integer, LE As Integer 'or byte if you have a arrays smaller than 256
'Loading UDT
ff = FreeFile
Open file For Binary As ff
Get #ff, , LS
Get #ff, , LE
ReDim n.LineStart(LS)
ReDim n.LineEnd(LE)
Get #ff, , n
Close ff
'Saving UDT
ff = FreeFile
Open file For Binary As ff
LS = UBound(n.LineStart)
LE = UBound(n.LineEnd)
Put #ff, , LS
Put #ff, , LE
Put #ff, , n
Close ff
-