aran armath
2010-05-10 22:00:26
I want to get scar to read each line from a .txt file one by one and insert into the script. Any way to do this?
2010-05-10 22:00:26
2010-05-10 22:04:43
2010-05-10 22:09:49
From: Sex
Yes just read the file and explode it based on the new line/carriage return characters.
2010-05-10 22:36:03
const
FileName = ''; //exact location of file
var
file: longint;
s: String;
begin
file:= OpenFile(FileName, false);
ReadFileString(file, s, FileSize(file));
CloseFile(file);
writeln(s);
end.
program FileReading;
const
FileName = ''; //exact location of file
var
i: integer;
file: longint;
s: String;
s2: TStringArray;
begin
file:= OpenFile(FileName, false);
ReadFileString(file, s, FileSize(file));
CloseFile(file);
//writeln(s); //writes the file
S2:= Explode(Chr(13), s);
for i:= low(S2) to high(S2) do
writeln(S2[i]); //writes each index of the String Array, each index is up to the return key (or should be)
end.
2010-05-11 05:38:38
program new;
var
x : TStringList;
i : integer;
begin
x := TStringList.Create;
x.LoadFromFile('c:\mytestfile');
for i := 0 to x.count - 1 do
writeln(x[i]);
x.free;
end.2010-05-11 12:41:01