WriteFile()/tile editor saving problems...

BlitzPlus Forums/BlitzPlus Programming/WriteFile()/tile editor saving problems...

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

hi I'm working on an RPG and I just made this simple tile editor which works fine but I am now trying to get loading/saving to work...Here's the code. I used writefile nd writeInt to try and save which 'frame' to use for each tile ie. which tile.
The problem is that when I open the file after writing it with Blitz, all I get is a '[]' (wierd box)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Graphics 800,600,16,1

AppTitle "Editor"

SetBuffer BackBuffer()

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Const width=800
Const height=600

Const kLeft=203
Const kRight=205
Const kUp=200
Const kDown=208

Const Kz=44
Const kx=45
Const Kc=46
Const Kspace=57

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Type tile
	Field which
	Field x#,y#
	Field xn#
	Field yn#
	Field water
	Field passable
	Field ident
End Type

Global grasstiles=LoadAnimImage( "C:/RPG/tiles/grass.bmp",32,32,0,52 )
Global mudties=LoadAnimImage( "C:/RPG/tiles/mud.bmp",32,32,0,52 )
Global cursor=LoadImage( "C:/RPG/cursor.bmp" )
MaskImage cursor,255,0,255

Global cx=1,cy=1,cimg=0,curdent=100,status=0,set=0

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

While Not KeyHit(1)

Cls

	Select set
	
	Case 0
	tiles=grasstiles
	
	Case 1
	tiles=mudtiles
	
	Default
	tiles=grasstiles
	
	End Select

	If Not status=1 Then
	
	If KeyHit(15) And set=0 Then
		set=1
	EndIf
	
	If KeyHit(15) And set=1 Then
		set=0
	EndIf
	
	If KeyHit(31) And cimg<52 Then
		cimg=cimg+1
	EndIf
	
	If KeyHit(30) And cimg>0 Then
		cimg=cimg-1
	EndIf
	
	If KeyHit(57) Then
		t.tile=New tile
		t\x=cx
		t\y=cy
		t\which=cimg
		t\ident=curdent
		
		curdent=curdent+1
	EndIf
	
	If KeyHit(19) Then
	EndIf
	
	If KeyHit(Kz) Then
	status=1
	EndIf
			
	
	For t.tile = Each tile
		DrawImage tiles,t\x,t\y,t\which
	Next	
	
	
	If KeyHit(Kright) Then
		cx=cx+32
	EndIf
	
	If KeyHit(Kleft) Then
		cx=cx-32
	EndIf
	
	If KeyHit(Kdown) Then
		cy=cy+32
	EndIf
	
	If KeyHit(Kup) Then
		cy=cy-32
	EndIf
	
	If KeyHit(42) Then
	Color 100,140,150
	Text width/2,height/2,">>Saving<<",True,True
	name= WriteFile(CurrentDir()+"/levels/first_level")
	For t.tile = Each tile
	WriteByte(name,t\which)
	Next
	EndIf
	
	
	DrawImage tiles,cx,cy,cimg
	Color 255,255,255
	Rect cx-1,cy-1,34,34,False
	Text cx+35,cy,"Tile no: "+cimg
	For t.tile = Each tile
	If RectsOverlap(cx,cy,32,32,t\x,t\y,32,32) Then
	Text cx+35,cy+15,"Tile ident: "+t\ident
	EndIf
	Next
	
	Else
	
	window(200,10,350,560,50,90,30,"Tile editor V1.0")
	button(230,50,60,20,30,130,20,"Save")
	
		
	If KeyHit(Kz) Then
	status=0
	EndIf
	
	DrawImage cursor,MouseX(),MouseY()
	
	EndIf	

Flip

Wend

Function window(x#,y#,ys#,xs#,r#,g#,b#,title$)

Color 50,50,50
Rect x,y,ys,xs,True

Color 255,255,255
Text x+2,y-5,title,False

Color 255,255,255
Rect x+7,y+7,ys-7,xs-7,False

Color r,g,b
Rect x+17,y+17,ys-27,xs-27,True

End Function

Function button(x#,y#,xs#,ys#,r#,g#,b#,title$)

Color r,g,b
Rect x,y,xs,ys,True

Color 255,255,255
Rect x,y,xs,ys,False

Color 255,255,255
Text x+(xs/2),y+(ys/2),title,True,True


End Function


Please help me with this as it's pretty much the only thing stopping me from making a great RPG :[