[fpc-pascal] FindFirst...FindClose

Michael Van Canneyt michael at freepascal.org
Mon May 18 18:15:13 CEST 2009



On Mon, 18 May 2009, Jonas Maebe wrote:

>
> On 18 May 2009, at 17:25, Michael Van Canneyt wrote:
>
>> On Mon, 18 May 2009, Jonas Maebe wrote:
>> 
>>> On 18 May 2009, at 16:39, Leonardo M. Ramé wrote:
>>> 
>>>> By reading the FPC.RTL documentation, I found it says that FindClose must 
>>>> be
>>>> used outside the if, as follows:
>>>> 
>>>> if FindFirst(Edit1.Text, FileAttrs, sr) = 0 then
>>>> begin
>>>> repeat
>>>> ...
>>>> ...
>>>> until FindNext(sr) <> 0;
>>>> end;
>>>> FindClose(sr);
>>>> 
>>>> Can be this the cause of the problem in my application?.
>>> 
>>> Yes.
>> 
>> Huh ? Since when is this requirement ?
>
> Since as long as I can remember. It at least predates the switch to svn 
> (revision 1 of both rtl/unix/dos.pp and of rtl/unix/sysutils.pp requires it).

As far as I know, the FindClose is only needed when FindFirst returned zero.
At least, that's what you can deduce from MSDN, and this is how I programmed
it since ages.

Michael.


More information about the fpc-pascal mailing list