Promotic

FileFind - method of the Pm object

Description:
Search for files and folders in the specified path.
Syntax:
Variant FileFind(String sPath, String sName, Long nAttr)
Parameters:
sPath(String) Path where to find the files.
It is recommended to use the PROMOTIC path syntax - see PROMOTIC path to files and folders.
sName(String) File names that have to be found; "wild" characters * and ? can be used
nAttr(Long) Bit attribute. The value je a bit combination:
1 - Don't look in subfolders
2 - Return absolute paths
4 - Find even folders
8 - Find only subfolders; overwrites attribute 4
16 - The output array is sorted by creation time of files
32 - The output array is sorted by file name
64 - The output array is sorted by the file extension
128 - The output array is sorted bottom-up (from the smallest to the biggest = aa, ab, ba, bb, c, d ...). Otherwise the sorting is top-down (from the biggest to the smallest = zz, zy, yz, yy, x, w, ...). Value 0 = means to find only files, not folders.
256 - File names will be returned without the extension
512 - Sorts the output array by the last write time into the file
Return value:
The method returns always the items array of the String type.
If only one file has been found, then the array has only one item.
If no file has been found, then the array has no items (upper index UBound=-1).
Note:
Relative path (if nAttr AND 4 is not set) refer to the beginning of the search (file names are added to files in subfolders, for example "file.ini", "DATA/file.dat").

This method is not functional in Web panels.
Example1:
Search for INI files in the application folder, their listing without looking in subfolders and sorting by names bottom-up. Returns absolute paths to the files.
JavaScriptVBScriptSelect and copy to clipboard

var aFiles, nFiles, iFiles;
aFiles = Pm.FileFind("#app:", "*.INI", 1 + 2 + 32 + 128);
nFiles = aFiles.GetSize(1);
for (iFiles = 0; iFiles < nFiles; iFiles++)
{
Pm.Debug(aFiles.GetItem(iFiles));
}
Example2:
Search for app.txt file in the application folder. Returns absolute path to the file.
JavaScriptVBScriptSelect and copy to clipboard

var aFiles, nFiles;
aFiles = Pm.FileFind("#app:", "app.txt", 1 + 2 + 32 + 128);
nFiles = aFiles.GetSize(1);
if (nFiles != -1)
{
Pm.Debug(aFiles.GetItem(0));   // File found
}
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
Navigation:
 
- Pm
 
- Abs
- Cos
- E
- Exp
- FileFind
 
 
- LN2
- PI
- Pow
- Sin
- Tan
© MICROSYS, spol. s r.o.