File :: Readstructure (), WriteStructure () functions
Posted: Sun Jan 17, 2016 9:50 pm
The VB6 had nice thing that PB still misses for some reason - writing whole structure to a file.
For example here is structure with dynamical string.
It saves to file only pointer value of a string, which is useless.
If using same code with VB6 it saves and reads the whole string itself, not a pointer. Which is very useful and you don't have to write your own bloated module to pack every structure manually.
For example here is structure with dynamical string.
Code: Select all
Structure test
s.s
EndStructure
Define X.test
X\s = "1234"
CreateFile(1, "D:\1.txt")
WriteData(1, @X, SizeOf(X))
CloseFile(1)
If using same code with VB6 it saves and reads the whole string itself, not a pointer. Which is very useful and you don't have to write your own bloated module to pack every structure manually.
Code: Select all
Option Explicit
Private Type Test
s As String
End Type
Private Sub Command1_Click()
Dim X As Test
X.s = "1234"
Open "D:\1.txt" For Binary As 1
Put 1, 1, X
Close 1
Dim Y As Test
Open "D:\1.txt" For Binary As 1
Get 1, 1, Y ; not even size to read specified. Y is not exactly as X
Close 1
Debug.Print Y.s
End Sub