Re: [fpc-pascal] accessing files from a function

2011-05-16 Thread Anton Shepelev
Rainer Stratmann: > Alternatively you can make a class or an object with the > text variable in it. But if you need to work with only one file, you can get rid of a global variable in the main module by just extracting the relevant functions and the file handle into a separate unit: -

Re: [fpc-pascal] accessing files from a function

2011-05-16 Thread Doug Chamberlin
On 5/15/11 8:28 PM, 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

Re: [fpc-pascal] accessing files from a function

2011-05-16 Thread Rainer Stratmann
Am Monday 16 May 2011 12:28:19 schrieb johnelee1...@googlemail.com: > thanks all - btw it wasn't the real code just an example I made up , the > while loop wasn't needed- mistake! > > But the q still remains - having three functions would still give the > problem I have now- that when doing a file_

Re: Re: [fpc-pascal] accessing files from a function

2011-05-16 Thread dhkblaszyk
On Mon, 16 May 2011 10:28:19 +, johnelee1...@googlemail.com wrote: > thanks all - btw it wasn't the real code just an example I made up , the while loop wasn't needed- mistake! > >But the q still remains - having three functions would still give the problem I have now- that when doing a f

Re: Re: [fpc-pascal] accessing files from a function

2011-05-16 Thread johnelee1944
thanks all - btw it wasn't the real code just an example I made up , the while loop wasn't needed- mistake! But the q still remains - having three functions would still give the problem I have now- that when doing a file_read (my function flag=1) would say 'file not open' because the handle

Re: [fpc-pascal] accessing files from a function

2011-05-16 Thread Rainer Stratmann
In my eyes it is (very) unlogic. Why don't you make 3 functions? Something like this... var filename : string; // global var for storing the filename function file_reset( name : string ) : boolean; function file_read( var eof : boolean ) : string; function file_close : boolean; Whith your examp

Re: [fpc-pascal] accessing files from a function

2011-05-15 Thread London Disney
well why not make it a global variable in that unit's implementation? implementation var f:text . then have a separate function to close the file. On 16 May 2011, at 01:28, John Lee wrote: > I'd like to put the assign and reset of a text file into a function, and then > use the

Re: [fpc-pascal] accessing files from a function

2011-05-15 Thread Ralf A. Quint
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. Th