@Daniel,
Here is another method using GetStringToken(str,delimit,token)
// Project: RPGloadingTMX
// Created: 2014-10-19
// set window properties
SetWindowTitle( "RPGloadingTMX" )
SetScreenResolution( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
Type _TMX
width as integer
height as integer
layers as integer
resx as integer
resy as integer
spritesheet as string
EndType
Type _Map
sprite as integer
data as integer
EndType
Global Map as _TMX
LoadTMX( "map.tmx" )
do
Print( Map.width )
Print( Map.height )
Print( Map.resx )
Print( Map.resy )
Print( Map.spritesheet )
Print( Map.layers )
Print( ScreenFPS() )
Sync()
loop
Function LoadTMX( File$ )
file = OpenToRead( File$ )
// ****** extract header info ******
//Discard first line
ReadLine( file )
//Get second line
tmp$ = ReadLine( file )
//extract width, height, resx and resy using Chr(34) aka " as the delimiter
Map.width=Val(GetStringToken(tmp$,Chr(34),8))
Map.height=Val(GetStringToken(tmp$,Chr(34),10))
Map.resx=Val(GetStringToken(tmp$,Chr(34),12))
Map.resy=Val(GetStringToken(tmp$,Chr(34),14))
//Discard third line
ReadLine( file)
//Get forth line
tmp$ = ReadLine( file )
//extract spritesheet filename
Map.spritesheet=GetStringToken(tmp$,Chr(34),2)
// *************** end **************
// **** counting layers *************
Repeat
tmp$ = ReadLine( file )
If tmp$ = " </layer>"
Map.layers = Map.layers + 1
EndIf
Until FileEOF( file ) = 1
// *************** end **************
CloseFile( file )
Dim mapdata[ map.height, map.width, map.layers ] as _Map
EndFunction
It works, but it is not nearly so much fun