InfoFile() function
- Last UpdatedJul 22, 2024
- 2 minute read
Returns various information on a file or directory.
Syntax
result = InfoFile (filename, infotype, trigger)
Parameters
filename
The full file name or directory name you want to retrieve information about. A literal string value, message tagname, or string expression. Can also include wildcard characters, such as "*" and "?".
infotype
The type of information you want to retrieve about the specified file or directory. A literal integer value, integer tagname, or integer expression with following values and meaning:
1 - Existence. The InfoFile() function returns 1 if the file exists, 2 if the file is a directory and 0 if the file or directory does not exist.
2 - Size. The InfoFile() function returns the file size in bytes.
3 - Creation timestamp. The InfoFile() function returns the time stamp as seconds that have passed since midnight January 1, 1970. Use the StringFromTimeLocal() function to convert this value to a message timestamp.
4 - Wildcard Search Match. The InfoFile() function returns the number of files that match a specified wildcard search.
trigger
A tagname (or expression) that acts as a trigger to recalculate the file information. If the trigger value changes, the file information is recalculated. A discrete or analog taname, or a discrete or analog expression.
Remarks
The trigger tag only has meaning when the InfoFile() function is used in an animation display link. If this function is used in a script, you can specify any literal numeric value, analog tagname, or numeric expression.
Example(s)
This script returns 1 if the file c:\data\log.txt exists.
InfoFile("c:\data\log.txt",1,$minute)
This script returns 14223 if the file c:\data\log.txt has a file size of 14223 bytes.
InfoFile("c:\data\log.txt",2,$minute)
This script returns 1138245266 if the file c:\data\log.txt was created on January 26, 2006 at 11:14:26 AM.
InfoFile("c:\data\log.txt",3,$minute)
This script returns 14 if there are 14 files in the directory c:\data\ that have a txt ending.
InfoFile("c:\data\*.txt",4,$minute)