$file-names - Filtered file name list
$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 takes the form of a regex. 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.
Copyright (c) 1998-2006 JASSPA
Last Modified: 2002/01/11
Generated On: 2006/10/07