2Bh FL$FFND find filename
Input X = address of search string
A = length of search string
B = record type to be searched
Output RTB_BL = file name
Description

Searches through all the records of a particular type on current datapack for a record beginning with a given search string. The search string is at X of length A. B is the record type.

To find a file name or a block file name, use a search string padded out to eight characters with spaces, otherwise searching for ABC, for example, will also find ABCD etc. The search string should not include a device name A: B: etc.

The most common use of FL$FFND is in finding OPL procedure names, in which case B = $83. To find a filename, use B = $81. To find a block file name use the appropriate block file type, between $82 and $8F inclusive. A should be set to 8 in each case.

FL$FFND will fail unless the records are known to be at least as long as the search string.

If found, the file name which matches the search string is returned at RTB_BL as a leading byte count string, else error end of file is reported.

Example To find the OPL procedure "POKEY" on device C:
        LDAB    #2             ; set current device in use by file system
        OS      FL$SETP        ; to C:  -- 0 for A:, 1 for B: etc.
        BCS     ERROR

        LDX     #SEARCH        ; address of search string
        LDAA    #8             ; length of search string
        LDAB    #83h           ; block file type for OPL procedures
        OS      FL$FFND        ; FIND IT
        BCC     FOUND

        CMPB    #238
        BNE     ERROR
        ...
NOT_FOUND:
        ...
FOUND:
        ...

SEARCH: ASCII   "POKEY   "
                     ; 3 spaces
Errors 194 - battery too low
200 - read pack error
238 - end of file
240 - unknown pack
241 - pack not blank
243 - bad device name
245 - write pack error
246 - no pack