Detects a newline in a textfile and then writes it in the debug box. You can also just add it to an array of string if you want.
SCAR Code:
program New;
var
oDialog: TOpenDialog;
i, a : integer;
txtFile: Integer;
TextFileLines : string;
txtPath : string;
begin
//thx scar test files for half of this code.
oDialog := TOpenDialog.Create(nil);
oDialog.Filter := 'SCAR Scripts|*.scar|Text Files|*.txt|All Files|*.*';
if oDialog.Execute then
txtPath := oDialog.FileName;
txtFile:= OpenFile(txtPath, False);
if(txtFile > -1)then
begin
ReadFileString(txtFile, TextFileLines, FileSize(txtFile));
CloseFile(txtFile);
end;
//I tried TStringList; didn't work well.
ClearDebug;
repeat
i := pos(chr(13), TextFileLines);
Writeln(Copy(TextFileLines, 1, i - 1));
Delete(TextFileLines, 1, i);
until pos(chr(13), TextFileLines) < 1
Writeln(Copy(TextFileLines, 1, Length(TextFileLines)));
end.