Date : Tue, 15 Oct 1985 07:25:52 mdt
From : Richard Thomsen <rgt%a@LANL.ARPA>
Subject: Help on CP/M Find First/Find Next
Paul,
Thanks for your help, but that is what I tried. Please look at my
code, which I got from _The CP/M Programmer's Handbook_ by Andy Johnson-Laird.
I have the address of the ambigious filename in reg HL, and the unambigious
file name in reg DE. I search for the "destination" FCB (the one found last
time), then search for the next one using the ambigious FCB, which I have
copied into the "destination" FCB. In one case, it never finds the second
filename. In another case, it finds 17 out of 25 filenames. I can see no
patterns in what it does and does not find.
My code is not exactly like that in the book,
but the idea is the same.
Excerpted from my subroutine to get first/next filename.
The entire subroutine was posted last time. This is just the part that
finds the NEXT filename. The DMA buffer has been set up already.
The "destination" FCB is the one that was filled last time from the one
found. The file name in that FCB has been opened and closed, using this
FCB. The "source" FCB is the ambigious file name used in the last
"find first/find next" call to this subroutine.
;
; Request is to get the next file name -- search for next
; First, the context of the file name must be restored by again
; searching for the last one found.
;
GNFNEXT:
POP H ;Recover address of source file name FCB
POP D ;Recover address of destination FCB
PUSH H ;Save them again, but in opposite order
PUSH D
CALL GNFZEROFILE ;Clear all but the name from the FCB
POP D ;Recover the destination FCB address
PUSH D ;And save it again
MVI C,SEARCHF ;Get code to search for the last file found
CALL BDOS ;And re-find that file
;
; Now the FCB is set to what it was at the end of the last search.
; Move the source FCB into the destination FCB and search for the next.
;
POP D ;Get the address of the destination FCB
POP H ;Get the address of the source FCB
PUSH D ;Save them again in the opposite order
PUSH H
PUSH D ;Save address of destination FCB again
MVI C,FCBSIZE ;Get the size of the FCB's
CALL MOVE ;Set the destination FCB to the source FCB
;
; Now call the BDOS to search for the next occurance of the FCB
;
POP D ;Get address of destination FCB
CALL GNFZEROFILE ;And clear all but the name
MVI C,SEARCHN ;Get code to search for next file name
CALL BDOS ;Call the BDOS to do the search
POP H ;Restore the address of the source FCB
POP D ;Restore the address of the destination FCB
CPI 0FFH ;See if file was found
JZ GNFFILENOTFND ;If not, then just exit with error
;
; File was found -- save the filename found in the save area for
; next search
;
GNFGETFCB: