Hi!
I've a problem with the function ReadStringback
In my game I keep trace of the six best scores in a file setup.dat.
initialisation in game_start
Code: ags
The name of the 6 best players and the scores are initialised to "Player i" and 0.
In the high score room there is this code to read the six scores and put them in six labels of a GUI
Code: ags
instead at the end room there is a GUI to insert the name and if you press ok it activates this code
Code: ags
I run the game and when I enter room 2 and three (2nd and 3rd piece of code) there is an error
"File.ReadStringback : File was not written by WriteString"
But the file IS written by WriteString.
What's the problem?
Thanks for your help in advance
I've a problem with the function ReadStringback
In my game I keep trace of the six best scores in a file setup.dat.
initialisation in game_start
File* hischandle=File.Open ("setup.dat",eFileRead);
if (hischandle==null) {// file not exists, create one.
Ã,Â
hischandle=File.Open ("setup.dat", eFileWrite);Ã,Â
int i=0;
while(i<6)
{
Ã, String str= String.Format("Player %d",i);
hischandle.WriteString(str);
hischandle.WriteInt (0);Ã,Â
i++;
}
}
hischandle.Close();
The name of the 6 best players and the scores are initialised to "Player i" and 0.
In the high score room there is this code to read the six scores and put them in six labels of a GUI
int i=0;
String punteggi[6]; //labels with name +point
String giocatore; //temp variable for player
int hiscore; //temp variable for high score
File* hischandle=File.Open ("setup.dat",eFileRead);
while(i<6)
{
Ã,Â
Ã, giocatore=hischandle.ReadStringBack();
Ã, hiscore=hischandle.ReadInt();
Ã, punteggi[i]=String.Format("%s: %d",giocatore, hiscore);
Ã, i++;
Ã,Â
}Ã,Â
hischandle.Close();
lblHS1.Text= punteggi[0];
lblHS2.Text= punteggi[1];
lblHS3.Text= punteggi[2];
lblHS4.Text= punteggi[3];
lblHS5.Text= punteggi[4];
lblHS6.Text= punteggi[5];
instead at the end room there is a GUI to insert the name and if you press ok it activates this code
gInsert.Visible=false; //insert name gui
lblName.Text=nameTB.Text;
if(nameTB.Text=="")lblName.Text="Giocatore";
File* hischandle=File.Open ("setup.dat",eFileWrite);
int i=0;
String names[6];
int points[6];
while(i<6)
{
names[i]=hischandle.ReadStringBack();
points[i]=hischandle.ReadInt();
i++;
}
//controls if current score is better than one of the high score etc
Ã,Â
I run the game and when I enter room 2 and three (2nd and 3rd piece of code) there is an error
"File.ReadStringback : File was not written by WriteString"
But the file IS written by WriteString.

What's the problem?
Thanks for your help in advance