Code: Pascal [Select]Var F:Text; Buffer:ShortString;begin Result := false; Try Try AssignFile(F,FileName); Reset(F); //... except on e:Exception do ShowMessage(e.ToString); end; finally Close(F); end;end;
SL.LoadFromFile(AFilename); SL.Text := WinCPToUTF8(SL.Text);
Regarding your suggestion to reset the file before the try block ... what if Reset fails? In that case I get an unhandled exception.
@J-G: IOresult :-) Back to the 1980 Programming techniques :-) I thought about this in the beginning, but then decided to go with try blocks, otherwise everyone would realize that I am already over 50 years old :-)
Yuck. Is this really the only way to get a text read loop with exception handling?