writefile??

BlitzMax Forums/BlitzMax Beginners Area/writefile??

FBEpyon(Posted 2005) [#1]
If KeyHit(KEY_F2) Then SaveMap("map/test.som")


Function SaveMap:Int (file:Object)

Local f:Int
Local fx:Int, fy:Int, fl:Int

f = WriteFile(file)

For fx = 0 To 32
For fy = 0 To 32
WriteInt f, tilemap[fx,fy,0]
Next
Next

CloseFile f

End Function

why doesn't this work??


gman(Posted 2005) [#2]
what problem are you having? the first thing i see offhand is the variable f. it should be of type TStream:
Local f:TStream

my guess is that will clear things up. if it doesnt, have you put DebugLog statements in there to check how far your getting? right along with the WriteInt put a DebugLog of the same info and see whats trying to being written.


klepto2(Posted 2005) [#3]
Try to add:

Createfile(file) before the writefile command.
and try the above post.


Yan(Posted 2005) [#4]
When you say doesn't work, what happens?

Is the file created at all?

Also, If you're going to use an integer file handle, don't forget to release it before you exit the function.


Booticus(Posted 2005) [#5]
He got it working. :)