Pattern Matching And Wild Cards - Commodore 1541 User Manual

Hide thumbs Also See for 1541:
Table of Contents

Advertisement

LOAD"$0:*
=
S"
,8
will load a directory of all
sequential
files, while the Basic
3.5
command:
DIRECTORY,
"A* =R"
will display a
direct~
consisting
only of relative files beginning with the letter
''A'•.
The possible file types
,
and their abbreviations for this use are:
P
=
Program
S
=
Sequential
R
=Relative
U
=User
D = Deleted
A= Append
M =Modify
PATTERN MATCHING AND WILD CARDS
Just as cassette users can load programs without giving a full name, disk
users
ci
use special pattern matching characters to load a program from a partial
name.
The
san
characters can also
be
used to provide selective directories. The two special
charactr
used in pattern matching are the asterisk
(*)
and the question mark
(?).
They
a
something
like a wild card in a game of cards. The difference between the two is
that
tl
asterisk makes all characters in and beyond its position wild, while the question mark
on
makes its own character position wild. Here are
some
examples,
and their
results:
LOAD
"
A* ",8 loads the first file on disk that begins with an
"A",
regardless1
what follows
.
"ARTIST", "ARTERY",
and
"AZURE"
would all qualify
,
b
"BARRY" wouldn't,
even
though it has an
"A"
elsewhere in
its
name
.
DLOAD
"SMITH"
(Basic 3.5) loads the first program that starts with "SM"
, em
with
"TH",
and has one other
character
between. This would load
"
SMITH
"
1
"SMYTH",
but not
"SMYTHE".
OPEN 8,8 ,2,''R?C* ,S,R" We'll
study
Open in Chapter
5,
but the pattern used
he
means that the
selected
file will begin with an
"R"
and have a "C" in the third
charac1
1
of its name.
DIRECTORY,"Q*"
(Basic 3.5)
will load a directory of files whose names
beg•
with
"Q".
LOAD"*"
,8
and DLOAD
"*"are
special cases. When an asterisk is used
alone
'
a name, it matches the last file
used.
If none have been used yet on the current
diskeV
since turning on the drive, using the asterisk alone loads the first program on the
disket1
1
10 INPUT A$
:
LOAD A$
+ "
* ",
8 loads any file whose name
starts
with
1
b
characters entered in A$
.
22
fORMAT
FOR PATIERN MATCHING
:
EXAMPLES:
.
*"
"express10n
"C-64*"
or
·•expression?expression''
"C?64
WEDGE"
or
'expression?expression*''
"C-64?WED*"
Use any of the above patterns in
any
of the disk
commands whose format
includes.
a
attem. This applies to Load, Dload, Directory
,
Open, Scratch
,
and
to the
source
file m
~e
Copy and Rename
commands.
More
than
one"?"
can
appear
in
the
same
pattern
..
As you might expect
,
their use
in
pattern matching means you
can't
use the asterisk
or
question mark in a file name when
saving
or writing a file
(see
next
chapter.)
23

Advertisement

Table of Contents
loading

Table of Contents