cook@gaia.UUCP (Forrest Cook) (09/10/87)
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. Any Suggesstions? Forrest Cook
mlinar@poisson.usc.edu (Mitch Mlinar) (09/11/87)
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
koko@uthub.UUCP (09/11/87)
According to "Inside CP/M" by David E. Cortesi, there should be no file operations intervening the Search for First and Search for Next, or intervening successive Search for Next operations, in some implementa- ations of CP/M. This may cause the BDOS do lose its place in the directory. (See p. 476 of the above text.)
mwilson@pnet01.cts.COM (Marc Wilson) (09/15/87)
Search for Next will only work without any intervening BDOS disk activity between it and the call to Search for First. Best way to do what you want is to repeatedly call Search/Next and load each name into a buffer, THEN do your processing. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Marc Wilson ARPA: ...!crash!mwilson@nosc.mil ...!crash!pnet01!pro-sol!mwilson@nosc.mil UUCP: [ cbosgd | hp-sdd!hplabs | sdcsvax | nosc ]!crash!mwilson INET: mwilson@crash.CTS.COM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~