Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Guyserman82 on Tue 31/08/2010 22:16:27

Title: Can AGS create and read text files?
Post by: Guyserman82 on Tue 31/08/2010 22:16:27
I'm thinking about making a RPG trilogy, and I want the character that the player creates to be usable through all three games. The simplest way I can think to do this is to have AGS create and read a text document. Is this possible?
Title: Re: Can AGS create and read text files?
Post by: Dualnames on Tue 31/08/2010 22:45:48
Of course it is. Below some examples. Depends on what you want really. A more specific question, would create a more specific answer.

CREATION

if (!File.Exists("temp.txt")){
  File *output = File.Open("temp.txt", eFileWrite);
  output.WriteString("A");
  output.Close();
}



Read

File *input = File.Open("temp.txt", eFileRead);
listbox.Clear();
if (input != null) {
  while (!input.EOF) {
    String line = input.ReadRawLineBack();
   listbox.AddItem(line);
   }
  input.Close();
}