home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug078.arc
/
PARSEFCB.DOC
< prev
next >
Wrap
Text File
|
1979-12-31
|
6KB
|
153 lines
Documentation for PARSEFCB.REL
October 31, 1983
Jim Lopushinsky
Entry Parameters:
Register DE: Address of input ASCII string
HL: Address of target FCB
Returned Value:
Register HL: Return code
PARSEFCB.REL is a subroutine that parses an ASCII file
specification and prepares a File Control Block, FCB. The
calling program places the address of the ASCII string in
register DE, and the address of the FCB in HL. The maximum
length of the input ASCII string to be parsed is 128 bytes. The
target FCB must be 36 bytes in length.
PARSEFCB has two entry points:
PARSE Standard parse with no user specification allowed.
This subroutine performs an identical function to
BDOS function 152, Parse Filename.
PARSEU Standard parse with optional user number
specified. This entry point actually requires the
FCB to be 37 bytes in length, with the user number
at FCB-1. PARSEU returns 0FFH at FCB-1 if no user
number was specified, or the specified user
number.
PARSE assumes the input string contains file specifications in
the following form:
{d:}filename{.typ}{;password}
PARSEU assumes the input string contains file specifications in
one of the following forms in addition to the form for PARSE:
{du:}filename{.typ}{;password}
{u:}filename{.typ}{;password}
{ud:}filename{.typ}{;password}
where items enclosed in curly brackets are optional. PARSE and
PARSEU also accept isolated drive/user specifications d:, du:,
u:, ud: (PARSE only accepts the first form) in the input string.
When it encounters one, it sets the filename, filetype, and
password fields in the FCB to blank.
The PARSE and PARSEU functions parse the first file specification
they find in the input string. The function first eliminates
leading blanks and tabs. The function then assumes that the file
specification ends on the first delimiter it encounters that is
out of context with the specific field it is parsing. For
instance, if it finds a period, and it is not parsing the
filename field, the period delimits the entire file
specification.
The parse routines recognize the following characters as
delimiters:
space
tab
return
null
; (semicolon) - except before password field
= (equal)
< (less than)
> (greater than)
. (period) - except after filename and before filetype
: (colon) - except before filename and after drive/user
, (comma)
| (vertical bar)
[ (left square bracket)
] (right square bracket)
If a non-graphic character is encountered in the range 1 through
31 not listed above, it treats the character as an error. The
FCB is initialized as shown below:
Location Contents
byte -1 (PARSEU only) The user field is set to the
specified user number. If the user number is not
specified, the user field is set to 0FFH.
byte 0 The drive field is set to the specified drive. If
the drive is not specified, the default drive code
is used. 0=default, 1=A, 2=B, etc.
byte 1-8 The name is set to the specified filename. All
letters are converted to upper-case. If the name
is not eight characters long, the remaining bytes
in the filename field are padded with blanks. If
the filename has an asterisk, *, all remaining
bytes in the filename field are filled in with
question marks, ?. An error occurs if the
filename is more than eight bytes long.
.pa
byte 9-11 The type field is set to the specified filetype.
If no filetype is specified, the type field is
initialized to blanks. All letters are converted
to upper-case. If the type is not three
characters long, the remaining bytes in the
filetype field are padded with blanks. If an
asterisk, *, occurs, all remaining bytes are
filled in with question marks, ?. An error occurs
if the type field is more than three bytes long.
byte 12-15 Filled in with zeros.
byte 16-23 The password field is set to the specified
password. If no password is specified, it is
initialized to blanks. If the password is less
than eight characters long, remaining bytes are
padded with blanks. All letters are converted to
upper-case. If the password field is more than
eight bytes long, an error occurs. Note that a
blank in the first position of the password field
implies no password was specified.
byte 24-25 Filled in with zeros.
byte 26 Length of the password.
byte 27-35 Filled in with zeros.
If an error occurs, 0FFFFH is returned in register pair HL.
On a successful parse, the function checks the next item in the
input string. It skips over trailing blanks and tabs and looks
at the next character. If the character is a null or carriage
return, it returns a 0 indicating the end of the input string.
If the character is a delimiter, it returns the address of the
delimiter. If the character is not a delimiter, it returns the
address of the first trailing blank or tab.
If the first non-blank or non-tab character in the input string
is a null, 0, or carriage return, the function returns a zero
indicating the end of the string.
If the function is to be used to parse a subsequent file
specification in the input string, the returned address must be
advanced over the delimiter before placing it in register DE.