<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Fri, 11 Sep 1987 00:43:22 GMT
From   : poisson.usc.edu!mlinar@OBERON.USC.EDU (Mitch Mlinar)
Subject: Re: BDOS Function: Search For Next

In article <329@gaia.UUCP> cook@gaia.UUCP (Forrest Cook) writes:
>Does anybody out there have any experience with the CP/M bdos calls
>Search for First and Search for Next?
>I am working on a program that needs to read every file off of a cp/m disk.
>I set the file name in the FCB to ????????.???.
>Search for First is called, and returns with the FCB pointing to the first
>file on the disk.
>The first file is opened, read, and closed successfully.
>Search for Next returns with file not found.  (There are more files).
>If I set the FCB to ????????.??? before doing the Search for Next, The
>function returns with the first file again.
>It seems like I am doing something wrong with the FCB.

I am sure there are thousands of others out there who can answer this one.
(Right, Bridger?)  Essentially, the problem is that whenever you do a
file operation such as Search, Open, or Close, the DOS goes off plucking
through your directory.  Hence, a Search must be followed by a Search for
Next if you want "more of the same".  Any Opens, Closes, Deletes, etc. destroy
the flow of things and you must start over.

Internally, there is a Search for Next directory counter which
keeps track of where the last Search was done AS WELL AS the address of the
FCB used for Search.  (Hence, the little known fact that Search for Next does
not require ANY FCB to be specified - it uses the FCB address from the
previous operation.)  Both the counter and the FCB addr are reset if any
other file operation is attempted (there are some exceptions).

Hope this helps.

-Mitch
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>