22h FL$BCAT list files
Input A = 1 for 1st call, 0 subsequently
B = device (0 to 3)
X = where to put filename (leading byte count)
UTW_S0+1 = block file type ($81 to $8F)
Output - none -
Description

When called repeatedly, returns each filename of a given record type on a device as a leading byte count string at the address given in X in the form D:NAME .

A is set to 1 before the first call to FL$BCAT and 0 on subsequent calls. When there are no more files in the directory the carry is set and B = 238 (end of file error).

B contains the device number - 0 for A:, 1 for B: etc. A record type of $81 in (UTW_S0+1) will do a directory of files, as in the OPL function DIR$. Any other value up to $8F inclusive will do a directory of block files of the given type.

Calling FL$BCAT with UTW_S0+1 = $81 is equivalent to calling FL$CATL. No error is reported if the block file type is outside the range $81-$8F, unless the block file type is less than $80.

Example
;       Do a directory of saved diaries

        LDAA    #1             ; A=1 first time FL$BCAT called
        BRA     FIRST
;       For each file in directory :

LOOP:   LDX     #TEMP           ; print leading byte count string in TEMP
        PSHX                    ; pass address to UT$DISP
        OS      UT$DISP
        DB      "%s"            ; show leading byte count string
        DB      13,10           ; CR LF
        DB      0               ; terminator for format string
        CLRA                    ; A=0 on subsequent calls to FL$BCAT 
FIRST:  LDAB    #82h            ; UTW_S0+1 = block file type for diaries   
        STAB    UTW_S0+1

        LDX     #TEMP           ; filenames be placed in TEMP by FL$BCAT
        LDAB    #MY_DEVICE      ; which device : 0 - 3 for A: to D:
        OS      FL$BCAT                                         
        BCC     LOOP            ; repeat until error returned
        CMPB    #238            ; end-of-file error means normal completion
        BEQ     DONE
ERROR:  ...                     ; otherwise report error

DONE:   ...

Errors 238 - file not found (normal completion)

194 - battery too low
200 - read pack err
237 - bad record type (if record type <$80 only)
240 - unknown pack
241 - pack not blank
243 - bad device name
245 - write pack err
246 - no pack