At 05:28 PM 5/15/2011, John Lee wrote:
I'd like to put the assign and reset of a text file into a function, and then use the function to return a line from the file, without needing to close the file then re assign and reset every time (for performance reasons) - see below for my attempt.

This doesn't work because I guess the file handles etc are local to the function are volatile, so cannot be accessed in the main program Is there a simple way to fix this ie to make this function work. Of course one can const in a function to make normal variables non volatile...but files etc?

TIA for any ideas...John
Only way would be if you pass the file as a parameter. But then you can put the file open sequence at the same place as you are calling the function with the "0" parameter and close it instead of calling with parameter "2".

Beside that, the function wouldn't work anyway, as
- for call with the "0" parameter, you don't get a line back, likewise negating any "saving" as you intend
- the while loop is nonsense, you would always get the last line of the file...

Ralf
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to