Talk:File Handling In Pascal
To Cjaster
Why do you use inttostr(IOResult) in
Writeln('ERROR! IORESULT: '+inttostr(IOResult));
Don't you get the same with the simpler
Writeln('ERROR! IORESULT: ', IOResult);
which has the additional advantage that you do not need "Uses Sysutils;"
I made an according change to the page and you simply reverted it without any comment or even reason. I appreciate the work you are putting to the wiki, but reverting without a comment hurts.
Could you please set up your user page. It would make feedback and discussion easier.
Thanks
MiSchi
which version of Pascal ?
What version of PASCAL is this code for ? I Use Borland TP7 and I get compilation errors. For eg. 'Sysutils' is not recognised, C style comments with // are treated as syntax errors, etc
- I guess it's for ObjFpc or Delphi mode (no idea about macpas etc). Bart 2015-09-21 19:14 CET
- It's for as what this wiki is for: Free Pascal. If you're talking about BP 7, you're late by 20+ years of modern Pascal development. --Leledumbo 11:23, 22 September 2015 (CEST)
Sample code may lead to orphaned open files !?
Looking at the sample code ...
try // Create the file, write some text and close it. rewrite(tfOut);
writeln(tfOut, 'Hello textfile!'); writeln(tfOut, 'The answer to life, the universe and everything: ', 42);
CloseFile(tfOut);
except // If there was an error the reason can be found here on E: EInOutError do writeln('File handling error occurred. Details: ', E.ClassName, '/', E.Message); end;
I'd suspect that if the writeln fails for some reason (disk full), the except block is executed and CloseFile is never executed. IMHO, on Windows, this will keep the file open until the application is closed, blocking any access to it.