(AGK version: 108.13)
Submitted: 2013-06-12 22:31:51
// Example 1 --- manually assign a file ID
OpenToWrite( 1 , "myFile.txt" )

// Example 2 --- automatically assign a file ID and append new data to the file
append = 1
fileID = OpenToWrite( "myFile.txt" , append)
(AGK version: 108.13)
Submitted: 2013-06-17 12:45:08
function LevelSave(filename$)

 file = OpenToWrite(filename$,0)

 Writeline(file,"Level Ball Labyrinth")

 WriteInteger ( file, Level.color )
 WriteInteger ( file, Level.style )

 //Hole x,y
 WriteInteger ( file, Level.holes )
 for i=1 to Level.holes
    WriteFloat(file,getspritexbyoffset(Level_Hole[i].spr))
    WriteFloat(file,getspriteybyoffset(Level_Hole[i].spr))
 next

 //Start x,y
 WriteFloat(file,getspritexbyoffset(Level.Start.spr))
 WriteFloat(file,getspriteybyoffset(Level.Start.spr))

 //Ende x,y
 WriteFloat(file,getspritexbyoffset(Level.Goal.spr))
 WriteFloat(file,getspriteybyoffset(Level.Goal.spr))

 //Block x,y,a
 WriteInteger ( file, Level.blocks )
 for i=1 to Level.blocks
    WriteFloat(file,getspritexbyoffset(Level_Block[i].spr))
    WriteFloat(file,getspriteybyoffset(Level_Block[i].spr))
    WriteFloat(file,getspriteangle(Level_Block[i].spr))
 next

 //Pin x,y,a
 WriteInteger ( file, Level.pins )
 for i=1 to Level.pins
    WriteFloat(file,getspritexbyoffset(Level_Pin[i].spr))
    WriteFloat(file,getspriteybyoffset(Level_Pin[i].spr))
    WriteFloat(file,getspriteangle(Level_Pin[i].spr))
 next

 //Wall x,y,a
 WriteInteger ( file, Level.walls )
 for i=1 to Level.walls
    WriteFloat(file,getspritexbyoffset(Level_Wall[i].spr))
    WriteFloat(file,getspriteybyoffset(Level_Wall[i].spr))
    WriteFloat(file,getspriteangle(Level_Wall[i].spr))
 next

 //Way x,y,a
 WriteInteger ( file, Level.waypoints )
 for i=1 to Level.waypoints
    WriteFloat(file,getspritexbyoffset(Level_WayPoint[i].spr))
    WriteFloat(file,getspriteybyoffset(Level_WayPoint[i].spr))
    WriteFloat(file,getspriteangle(Level_WayPoint[i].spr))
 next

 CloseFile ( file )

endfunction
Help make AGK better by submitting an example for this command!
(All examples are subject to approval)
Login to post an example of your own.