; ReadFile Example ; ---------------- ; Create a save-game file so there is something to read file=WriteFile("demo_savegame.dat") WriteString file,"Robo" WriteInt file,11657 CloseFile file ; ReadFile opens an existing file for reading. ; It returns 0 if the file cannot be opened - always check! file=ReadFile("no_such_file.dat") If file=0 Then Print "no_such_file.dat could not be opened (handle = 0)" ; Open the real save and read it back in the order it was written file=ReadFile("demo_savegame.dat") name$=ReadString$(file) score=ReadInt(file) CloseFile file Print "Loaded save: name="+name$+", score="+score ; Clean up the demo file DeleteFile "demo_savegame.dat" Print "Deleted demo_savegame.dat" Print "" Print "Press any key to close the example" WaitKey End