Hi.
I am using Lazarus 1.4.4, fpc Version 2.6.4. on Windows10.
I have written a simple program to find jpegs in files. It works successfully on a wide variety of files but on some .htm files it gives the message that the file that I have just selected in an Open dialog box can't be found.
This is the procedure:
procedure TForm1.Read;
Var
M, N, P: Integer;
Str: String;
begin
Memo.Lines.Add('File NAME - ' + Rdfil);
AssignFile(InFile, RdFil);
try
Reset (InFile);
except
on E : Exception do
ShowMessage(E.ClassName+' error raised, with message : ' + E.Message);
end;
Memo.Clear;
Memo.Lines.Add('File NAME - ' + Rdfil);
M := 0; P := 0;
While not EOF(InFile) do
begin
Inc (M);
ReadLn(InFile,Str);
Str := UpperCase(Str);
N := Pos('JPG', Str);
if N > 0 then
begin
Inc (P);
Memo.Lines.Add('JPG found in line ' + IntToStr(M));
end;
end;
Memo.Lines.Add(IntToStr(M) + ' lines read, ' + IntToStr(P) + ' Pictures found');
CloseFile(InFile);
end;
A typical example is:
http://www.formula1.com/.
I right click the page and use "save page as" to save it to an htm file and folder of other files.
I can open the hmt file in Aptana Studio3 and Notepad++ but my program fails at:
Reset (InFile);
If I delete sections of the html code in Notepad++ I eventually get to a file that my program can open, but if I have to do this on every file I try to open it makes my program useless.
I have tried opening this file using another program I wrote using Lazarus and got exactly the same problem.
Can anyone explain why Lazarus can't open all htm files.
Thanks.