$file-names - Filtered file name list
$file-names FileName
$file-names must first be initialized to the required filter string, if the variable is evaluated before it is initialized the value will be set to "ABORT" and the command will fail.
The filter string can contain wild-card characters compatible with most file systems, namely:-
?
[abc]
[a-d]
[^abc]
*
Note that these are not the same characters used by exact(2m) mode. The filter string should also contain the path to the required directory, the path many not contain wild-cards. If no path is specified the the path of the current buffers file name is taken, if the current buffer has no file name then the current working directory is used.
On initialization, $result(5) is set to the absolute path of the directory being evaluated.
Once initialized, evaluating $file-names returns the name of the next buffer which matches the filter until no more buffers are found, in which case an empty string is returned.
The following example creates a list of all files in the current directory to a fixed buffer "*files*". Note that &set(4) is used on the !while(4) statement to avoid evaluating $file-names twice per loop.
set-variable $file-names "*" !force 0 delete-buffer "*files*" 1 popup-window "*files*" insert-string &spr "Directory listing of %s\n\n" $result !while ¬ &seq &set #l0 $file-names "" insert-string &spr " %s\n" #l0 !done beginning-of-buffer -1 buffer-mode "edit" 1 buffer-mode "view"
Unlike MS-DOS and Windows systems, to match every file a filter of just "*" is required. A filter of "*.*" only matches file names with a '.' in them.
The list of files is evaluated when the variable is initialized, files created after the initialization will not be included in the list.
(c) Copyright JASSPA 1999
Last Modified: 1998/09/03
Generated On: 1999/12/01