Assembly Language Help (alang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
FindNext
 Map                                       Up Contents Index Back
────────────────────────────────────────────────────────────────────────────
 
;* FindNext - Finds next entry in given directory matching specification.
;* (Should be called only after successfully calling the FindFirst procedure.)
;*
;* Shows:   DOS Function - 4Fh (Find Next File)
;*          Operator - OFFSET
;*
;* Params:  Finfo - Pointer to 43-byte buffer. This must be the same buffer
;*                      (or a duplicate) returned from the FindFirst procedure.
;*
;* Return:  Short integer with error code
;*          0 if successful
;*          1 if no more matches found
 
FindNext PROC USES ds,
        Finfo:PFILEINFO
 
        ; Get current DTA address, pass address of pointer to hold value
        INVOKE  GetDTA,
                ADDR OldDta
 
        ; Set DTA address, pass pointer to structure
        INVOKE  SetDTA,
                Finfo
 
        mov     ah, 4Fh                 ; AH = function number
        int     21h                     ; Find Next File
 
        pushf                           ; Preserve flags
 
        ; Restore DTA address, pass pointer
        INVOKE  SetDTA,
                OldDta
 
        sub     ax, ax                  ; Set error code
        popf                            ; Recover flags
        .IF     carry?
        inc     ax                      ; Set error code to 1
        .ENDIF
        ret
 
FindNext ENDP
                                    -♦-