;WILDEN - wildcard expansion module for ZCPR3 tools ;Developed from Sigi Kluger's WILDEX by Bruce Morgen, ;6/5/91 ; ; This module, for use with SYSLIB, can be used ; to expand a wildcard filename into a table of ; file names as found in current DU: ; ; ENTRY: ; DE = .afn fcb ; DMA assumed to be default (80h) ; Buffer address is assumed to be a pointer stored ; at "$memry," start of the program is assumed to be ; "entry," a standard ZCPR3 header is also assumed, ; with the a file type of 1-4 located in the byte ; before the environment address pointer label ; "z3eadr." ; ; EXIT: ; HL = number of files ; ACC= zero flag reset (NZ) if ok, else error (Z). ; The buffer contains (HL) file names of 16 char each ; Char 0 contains the user number! ; snext equ 18 ; extrn bdos,f$exist,z3eadr,entry,$memry ; public wilden ; wilden: ld hl,($memry) ld a,(z3eadr-1) ; Get Z3 comfile type sub 4 ; Test for 4 ld (type4),a ; Stash test jr nz,not4 ; If not 4, use actual $memry, ld hl,entry-16 ; otherwise set up our own not4: ld (bufptr),hl ld hl,0 ld (count),hl call f$exist ; BDOS search_first plus INC A jr nz,wloop1 ; Move name and loop ret ; Nothing found -- error (Z, A=0) wloop: ld c,snext ; Search for next call bdos ; SYSLIB preserves BC and DE inc a ; Test for 0FFh jr z,done ; Finished wloop1: dec a ; Adjust BDOS return code add a,a ; Compute offset into TBUFF add a,a add a,a add a,a add a,a add a,80h ld bc,16 ; Move 16 chars ld l,a ; 8-bit pointer to L ld h,b ; Handy zero to H push de ; Stack FCB pointer ld de,(bufptr) ; Get buffer pointer ldir ; Move 'em out ex de,hl ; New buffer pointer into HL pop de ; Get back FCB pointer for caller ld a,(type4) ; Type 4? or a ; Test, also clears carry for SBC jr nz,not4a ; If not, use pointer as-is ld c,32 ; B = 0 from LDIR above sbc hl,bc ; Adjust pointer for Type 4 not4a: ld (bufptr),hl ld hl,(count) ; Bump file count inc hl ld (count),hl jr wloop ; done: ld hl,type4 ; Test for Type 4 cp (hl) ; without messing up A (A = 0) jr nz,not4b ; Not 4, don't change ($memry) ld hl,(bufptr) ; Otherwise change it for caller ld c,16 ; B = 0 from above if Type 4 add hl,bc ld ($memry),hl not4b: dec a ; Assure NZ and FFh in A ld hl,(count) ; Return count to caller ret ; ; dseg ; bufptr: ds 2 count: ds 2 type4: ds 1 end