SRL Archive - Help and Support

Hehe, Sorry, More File Handling Help... Please?


Timer

2008-01-31 23:01:21

Ok, More File Handling :p, How Would I Open A File, Then Have The File Become A String, Then (This Is Wat) Use Replace To Replace A Part Of The String, Then Re-Save The File ( Still Containing What Was Also In There, Only Change, In This Problem, The Score.

  TheFile := OpenFile('C:\Documents and Settings\Joe\Desktop\Bejewled Highscore.txt', False);
ReadFileString(TheFile, s, FileSize(TheFile));
Closefile(TheFile);
if (Score * 10) > StrToInt(Between('[Bejeweled HighScore]', '[/Bejeweled HighScore]', S)) then
begin
TheFile := ReWriteFile('C:\Documents and Settings\Joe\Desktop\HighScores.txt', False);
WriteFileString(TheFile, '[Bejeweled HighScore]' + IntToStr(Score * 10) + '[/Bejeweled HighScore]]');
Writeln('New HIGHSCORE!');
CloseFile(TheFile);
end;

so like..
  TheFile := OpenFile('C:\Documents and Settings\Joe\Desktop\Bejewled Highscore.txt', False);
ReadFileString(TheFile, s, FileSize(TheFile));
Closefile(TheFile);
if (Score * 10) > StrToInt(Between('[Bejeweled HighScore]', '[/Bejeweled HighScore]', S)) then
begin
TheFile := OpenFile('C:\Documents and Settings\Joe\Desktop\HighScores.txt', False);
WriteFileString(TheFile, Replace('[Bejeweled HighScore]', IntToStr(Score * 10), '[/Bejeweled HighScore]]'));
Writeln('New HIGHSCORE!');
CloseFile(TheFile);
end;

Help!? :(
Thanks
- Timer -