Save and load types

Blitz3D Forums/Blitz3D Beginners Area/Save and load types

Because your writing the type "handle" into the file. Not the data in the type.
And using an array of types? why not just use types? Makes it MUCH simpler.
for example.
See, Each type has an "ID" a "Naam$" and the other things, then you just save each of those into the file, then when you load em, make a new type and put that data into it.



Type WorkMenuType
	Field ID
	Field Naam$
	Field LinkID
	Field XPos
	Field YPos
	Field Width
	Field Height
End Type



For x = 0 To 100
	W.Workmenutype = New Workmenutype
	W\ID=10
	W\Naam$="JoeBob"
	;;Etc, fill in whatever you want.
Next

If FileType ("MyTest.typ") = 1
	DeleteFile "MuTest.typ"
EndIf

outfile = WriteFile ("MyTest.typ")
For W.workmenuType= Each Workmenutype
	WriteString(File,W\ID)
	WriteString(File,W\Naam$)
	;;Once again, etc. Fill whatever you want in.
Next 
CloseFile outfile

; All the above is working fine. when adding below an error comes up.

infile = ReadFile ("MyTest.typ")
While Not Eof(infile)
	W.Workmenutype = New Workmenutype
	W\ID=ReadString(file)
	W\Naam$=ReadString(file)
	;;Once again, etc. Fill in whatever else you want to add.
Wend 
	
	
CloseFile infile