Equinox Online Help - Language Reference - A to Z

Home

FileSearch

Applies to
SyntaxFileSearch FilespecExpression [, AttributeExpression, BufferItem]
Action[Statement] Searches for a file or set of files within a directory.
ScopeUsable anywhere
Notes

This statement searches for an individual file, first of a set of files, a volume label, a directory or first of a set of directories. Wildcard characters '*' & '?' can be used as part of the specification. The path and file specification is specified in FilespecExpression.

In order to make the file appear on the server, prepend "SERVER:" (in any case) to the FilespecExpression. This prefix is ignored by the single user version. If the path specification is a relative one, it will start from the program directory - the Eqserver.exe directory for server files, and the Equinox.exe or Equinet.exe directory for everything else.

ttributeExpression may contain one or more of the following letters, representing MSDOS file attributes:

  • N Normal
  • R ReadOnly
  • H Hidden
  • S System
  • V VolumeId
  • D Directory
  • A Archive

A combination of attributes may be used eg "NVD". If AttributeExpression is omitted, the statement looks for normal files by default.

If a matching file is not found, SysError is set to a non-zero value.

FileSearch is normally used in conjunction with FileSearchNext and FileDetails. FileSearch is used to find the first file matching FilespecExpression and subsequent matches are found using FileSearchNext; the details of each file may be retrieved using FileDetails.

The optional BufferItem argument receives a binary buffer which allows nested FileSearch operations using different buffer parameters. The variable supplied as the argument should be declared as a string without specifying a length: 'String SearchBuffer'.

The system workarea SysError is set to a non-zero value if an error occurs, otherwise zero.

After you have finished with the file information, call FileSearchClose.

CategoryFile Management
See Also ChooseFile, FileDelete, FileDetails, FileExists, FileHandle, FilePath, FileRename, FileSearch, FileSearchNext, MakeDirectory, RemoveDirectory
Example

This first example searches for a subdirectory called "MyApp" in the current directory.

FileSearch "MyApp", "D"

This more extensive method finds and displays the details of all form files in the current directory and all its sub-directories.

FindAllFiles "*.frm",""

procedure FindAllFiles String filespec, String filetype
string searchpos | last sub-directory found
string dir(14) | name of sub-directory
string spec(14) | file spec searched for
string path | current directory path

| list files in the current directory
FindFile filespec,filetype

| get the current directory and file specification
FilePath filespec,path,spec

| look for sub-directories in the current directory
FileSearch path & "*","D",searchpos

while not syserror
FileDetails dir

| ignore the special directories dot and dot-dot
if dir[1]<>"." then
| use the current function to check the subdirectory and any below
FindAllFiles path & dir & "\" & spec,filetype
end if

FileSearchNext searchpos
end while

FileSearchClose searchpos
end procedure | FindAllFiles


| list files of the required type in the current directory
procedure FindFile String filespec, String filetype
string name,path,type
date d
time t
long size

FileSearch filespec,filetype

if syserror then return

FilePath filespec,path
Print path

repeat
FileDetails name,type,d,t,size
print chr(9),name,type,d,t,size
FileSearchNext
until syserror

FileSearchClose
end procedure | FindFile