Thursday, 5 May 2011

file saving


Program Lesson9_Program2;
Var FName, Txt : String[10];
    UserFile   : Text;
Begin
 FName := 'Textfile';
 Assign(UserFile,'C:\'+FName+'.txt'); {assign a text file}
 Rewrite(UserFile); {open the file 'fname' for writing}
 Writeln(UserFile,'PASCAL PROGRAMMING');
 Writeln(UserFile,'if you did not understand something,');
 Writeln(UserFile,'please send me an email to:');
 Writeln(UserFile,'victorsaliba@hotmail.com');
 Writeln('Write some text to the file:');
 Readln(Txt);
 Writeln(UserFile,'');
 Writeln(UserFile,'The user entered this text:');
 Writeln(UserFile,Txt);
 Close(UserFile);
End.


Sub saveTopScores(ByRef TopScores() As TTopScore)
        Dim file As New System.IO.StreamWriter("HiScores.txt")
        For i = 1 To MaxSize
            file.WriteLine(TopScores(i).Name + "," + TopScores(i)
.Score.ToString())
        Next i
        file.Close()
    End Sub




No comments:

Post a Comment