Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!ll-xn!cit-vax!oberon!poisson.usc.edu!mlinar From: mlinar@poisson.usc.edu (Mitch Mlinar) Newsgroups: comp.os.cpm Subject: Re: BDOS Function: Search For Next Message-ID: <4389@oberon.USC.EDU> Date: Thu, 10-Sep-87 20:43:22 EDT Article-I.D.: oberon.4389 Posted: Thu Sep 10 20:43:22 1987 Date-Received: Sat, 12-Sep-87 15:42:53 EDT References: <329@gaia.UUCP> Sender: nobody@oberon.USC.EDU Reply-To: mlinar@poisson.usc.edu (Mitch Mlinar) Organization: University of Southern California, Los Angeles, CA Lines: 30 Keywords: Not Returning 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