<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Sat, 25 May 1985 13:34:38 mdt
From   : Richard Thomsen <rgt%a@LANL.ARPA>
Subject: Request for help on CP/M SEARCH NEXT command

       I need some CP/M help from the experts out there.

       I am trying to use the FIND FIRST/FIND NEXT calls from CP/M.
I have looked at _The_ _Programmer's_ _CP/M_ _Handbook_ by Andy
Johnson-Laird.  On page 105, he has an example that uses these calls.
He uses FIND FIRST to refind the previous file name, then changes the
FCB to the ambiguous file name, and uses FIND NEXT to find the next
matching ambiguous file name.

       However, when I try that, it comes back with No Such File.
It does not search for the next match of the ambiguous file name, but
searches for another copy of the previous file name (I guess).
Since I cannot give an FCB address to FIND NEXT, I assumed that it
used the last FCB address given.  But changing that FCB does not matter;
it still does not find any files.

       A sample of the code follows:

               LXI     D,FCB           ;Get the FCB address
               CALL    ZEROFCB         ;Clear out all but disk, name, & type
               LXI     D,FCB           ;Get the FCB address
               MVI     C,SEARCHF       ;Get the code for search for first
               CALL    BDOS            ;Re-find the last file
               LXI     H,FCB+1         ;Get address of the FCB
               MVI     A,'?'           ;Change it to ambiguous
               MVI     C,11            ;Get size of name and type
       LOOP:   MOV     M,A             ;Store ambiguous file name
               INX     H               ;Increment to next position
               DCR     C               ;Decrement count
               JNZ     LOOP            ;Loop for all bytes in name and type
               LXI     D,FCB           ;Get the FCB address
               CALL    ZEROFCB         ;Clear out all but disk, name, & type
               LXI     D,FCB           ;Get the FCB address
               MVI     C,SEARCHN       ;Get code for search for next
               CALL    BDOS            ;Search for next file
               CPI     0FFH            ;See if file was found
               JZ      FILENOTFOUND    ;If not, then error

       (This is not the exact code, but this is essentially what I did
by using DDT)  I realize there is probably some really dumb error, but I
cannot get it to work.  It always comes back with reg A = 0FFH with the
file not found.  Yes, there are more files on the disk.

       Any ideas would be welcome and greatly appreciated.

                                               Richard Thomsen
                                               rgt@lanl

PS:     As all know, CP/M is a trademark of Digital Research.
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>