EXPANDWILD Procedure ExpandWild in module WILDCARD takes a CP/M ambiguous file name as an input string, and returns an alphabetized linked list of the matching file names currently on the disk. You will need the following definitions to use ExpandWild: ---------------------------------------------------------------- type FileName = packed array [1..14] of char; {d:filename.ext} FilePtr = ^FileDescr; FileDescr = record NameText: FileName; {name of a matching file} Next: FilePtr; {points to next name on the linked list} end; external procedure ExpandWild (Pattern: FileName; var FirstFile: FilePtr); ----------------------------------------------------------------- ExpandWild's first parameter is a pattern in the format of a CP/M "ambiguous file name." That is, it may contain '?' and '*' "wild card" characters. (It may also contain just a file name.) The pattern must be padded with blanks on the end. ExpandWild's second parameter is a variable parameter in which to store a pointer to a linked list of file names. ExpandWild will search the specified disk (or the default disk) and create a linked list of names of all files on the disk (in the current user number) which match the supplied pattern. These names are allocated on the heap (via the "new" procedure), and may be de-allocated (via the "dispose" procedure) when no longer needed. Example of use: ----------------------------------------------------------------- Program TestWild; type FileName = packed array [1..14] of char; {d:filename.ext} FilePtr = ^FileDescr; FileDescr = record NameText: FileName; {name of a matching file} Next: FilePtr; {points to next name on the linked list} end; LineType = string[127]; var Line: LineType; Pat: FileName; i: integer; Files, Oldname: FilePtr; external procedure ExpandWild (Pattern: FileName; var FirstFile: FilePtr); function upper(ch: char): char; begin {convert lower to upper case alpha} if (ch >= 'a') and (ch <= 'z') then upper := chr(ord(ch) - $20) else upper := ch; end; begin write('Enter ambiguous file name: '); readln(Line); while (Line[1] = ' ') and (length(Line) > 0) do delete(Line, 1, 1); {scan off leading blanks} i := 1; while (Line[i] <> ' ') and (i <= length(Line)) and (i <= 14) do begin {copy name} Pat[i] := upper(Line[i]); i := i + 1; end; for i := i to 14 do Pat[i] := ' '; {pad with blanks} ExpandWild(Pat, Files); {create list of file names} i := 0; while Files <> nil do begin {scan the whole list} writeln(Files^.NameText); {actual processing goes here} Oldname := Files; Files := Files^.Next; {go to next on chain} dispose(Oldname); {reclaim space} i := i + 1; {count the files} end; writeln('There were ', i:1, ' matching files.'); end. ----------------------------------------------------------------- This program may be linked as LINKMT TEST,WILDCARD,FULLHEAP,PASLIB/S It is not necessary to link FULLHEAP unless you care about reusing the space taken up by the linked list. The following will work just as well. LINKMT TEST,WILDCARD,PASLIB/S