WildcardFileSearch
WildcardFileSearch lets you use wildcard characters to search for files in a specified directory.
The results of the WildCardFileSearch function may vary depending on the operating system in use. Files in a Windows directory are sorted in alphabetical order while files in a UNIX directory are sorted in random order. Because the order of sorting varies between the operating systems, the identical WildCardFileSearch function executed against identical directories, one on Windows and one on UNIX, will yield different results.
This function is valid in TM1® TurboIntegrator processes only.
Syntax
WildcardFileSearch( Pathname, PriorFilename);
Argument |
Description |
---|---|
Pathname |
A pathname to files for which you want to search. The pathname must end in a filename, which can contain a wildcard sequence using the * and/or ? characters. The ? wildcard character matches any single character. The * wildcard character matches zero or more characters. |
PriorFilename |
The name of an existing file in the specified directory. This filename cannot contain wildcard characters. The wildcard search specified by the Pathname argument will commence AFTER this file. If you pass an empty string as the PriorFilename argument, the WildcardFileSearch function returns the first file that matches the wildcard sequence specified by the Pathname argument. |
Example
The following example shows the use of the WildcardFileSearch function to determine the first server log file generated in 2004:
file = WildcardFileSearch( 'C:\Program Files\Cognos\TM1\Custom\
TM1Data\SData\tm1s2004*.log', ' ');
This example returns the first file matching the wildcard sequence 'tm1s2004*.log' from the C:\Program Files\Cognos\TM1\Custom\TM1Data\SData\ directory.
Because server log files are named and saved with sequential time stamps, and because the second parameter to WildcardFileSearch is empty, the function returns the first server log file starting with the characters 'tm1s2004'. This would be the first server log file generated in the year 2004.
The following example shows the use of the WildcardFileSearch function to return the first server log file generated after tm1s20040211153827.log was generated:
file = WildcardFileSearch( 'C:\Program Files\Cognos\TM1\Custom\
TM1Data\SData\tm1s*.log', 'tm1s20040211153827.log
');
This example begins searching the C:\Program Files\Cognos\TM1\Custom\TM1Data\SData\ directory immediately after the tm1s20040211153827.log file, and returns the first subsequent file matching the 'tm1s*.log' wildcard sequence.
tm1s20040220175522.log is the first file that occurs after tm1s20040211153827.log and matches the wildcard sequence. Accordingly, the example returns tm1s20040220175522.log.