Int 21H [1.0] Function 29H (41) Parse filename

Parses a text string into the various fields of a file control block (FCB).

Call with:

AH = 29H

AL = flags to control parsing

Bit 3 = 1 if extension field in FCB will be

modified only if an extension is

specified in the string being parsed.

= 0 if extension field in FCB will be

modified regardless; if no extension is

present in the parsed string, FCB

extension is set to ASCII blanks.

Bit 2 = 1 if filename field in FCB will be

modified only if a filename is

specified in the string being parsed.

= 0 if filename field in FCB will be

modified regardless; if no filename is

present in the parsed string, FCB

filename is set to ASCII blanks.

Bit 1 = 1 if drive ID byte in FCB will be

modified only if a drive was specified

in the string being parsed.

= 0 if the drive ID byte in FCB will be

modified regardless; if no drive

specifier is present in the parsed

string, FCB drive-code field is set to

0 (default).

Bit 0 = 1 if leading separators will be scanned

off (ignored).

= 0 if leading separators will not be

scanned off.

DS:SI = segment:offset of string

ES:DI = segment:offset of file control block

Returns:

AL = 00H if no wildcard characters encountered

01H if parsed string contained wildcard characters

FFH if drive specifier invalid

DS:SI = segment:offset of first character after parsed filename

ES:DI = segment:offset of formatted unopened file control block

Notes:

This function regards the following as separator characters:

[1] : . ; , = + tab space / " [ ]

[2.0+] : . ; , = + tab space

This function regards all control characters and the following as terminator characters:

: . ; , = + tab space < > | / " [ ]

If no valid filename is present in the string to be parsed, upon return ES:DI + 1 points to an ASCII blank.

If the * wildcard character occurs in a filename or extension, it and all remaining characters in the corresponding field in the FCB are set to ?.

This function (and file control blocks in general) cannot be used with file specifications that include a path.

Example:

Parse the string fname into the file control block myfcb.

fname db 'D:QUACK.DAT',0 ; filename to be parsed

myfcb db 37 dup (0) ; becomes file control block

.

.

.

mov ah,29h ; function number

mov al,01h ; skip leading separators

mov si,seg fname ; address of filename

mov ds,si

mov si,offset fname

mov di,seg myfcb ; address of FCB

mov es,di

mov di,offset myfcb

int 21h ; transfer to MS-DOS

cmp al,0ffh ; check status

je error ; jump, drive invalid

.

.

.