Writing type to disc

BlitzMax Forums/BlitzMax Beginners Area/Writing type to disc

twistedcube(Posted 2005) [#1]
Could someone give and example of storing a type on disc and then reading it back in. It seems that writeline only likes strings :)

type test
field x:int
field y:int
end type

example:test
example.x=200
example.y=300

so some way for writing that to a file and reading it back in.

Thanks again

Twisted Cube


Drago(Posted 2005) [#2]
writeint would be the command you want.
have a look in the streams module doc section.


twistedcube(Posted 2005) [#3]
Oky sorry I should have put this in:
type test
field x:int
field y:int
field c:string
end type

example:test
example.x=200
example.y=300
example.c="test"

Now is there a way to write type into the file. I have done this with other languages then you could access randomly or seq etc. or do i have to write the first two with writeint and the last with writestring.I was just wondering if there was an easier cause I have a version working like that already. If it a large type just can get wordy and long.

Twisted Cube


John Pickford(Posted 2005) [#4]
In my B3D projects I use writeline for everything. Blitz handles the conversions fine.

writeline (stream,myfloat)

myfloat=readline (stream)

I prefer this as it makes the resulting files readable in notepad which makes it a lot easier to debug,

In fact I think Bmax has a far better float to string conversion.