This message was edited by zibadian at 2006-3-31 6:59:50
: didn't understand how to use TStringList, so i wrote little code:
: AsignFile...
: ...
: repeat
: var2:= var2+1;
: readln(file, var);
: until var1 = var2;
: ...
: that's how it was solved! =)
:
:
Here is a slightly better code, which also checks if the file is not empty:
while not eof(file) do
begin
var2 := var2+1
readln(file, var);
if var1 = var2 then Break;
end;
When using the TStringList variation:
var
FileContents: TStringList;
begin
FileContents := TStringList.Create;
FileContents.LoadFromFile('filename.txt');
// Use Filecontents
Line := FileContents[var2];
// until you don't need them
FileContents.Free;
end;