| || |
Search for a file
I am trying to write a function that can search a file from a local drive and send a status if it was found or not.
Can anyone help?
Re: Search for a file
If the file is supposed to be in a specific directory, you could simply do a file_open() on it and inspect the return code (0 if opened OK).
If you can't be sure where it will be, you could use dos_system() to generate a directory listing, then parse it with the file_*() functions and match() or index() to see if it's in the listing. Something along the lines of this (untested, so check syntax, etc.):
public function find_file(in dir, in file, out result)
result = "";
dos_system("dir /B /S " & dir & " > c:\\temp\\files.txt");
while(file_getline("c:\\temp\\files.txt", line) == E_OK)
if(index(line, file) > 0)
result = line;
'result' will be full pathname if found, else will be empty string.
my @email = qw(charles reace verizon net);
printf("%s.%s@%s.%s\n", $email, $email, $email, $email);
[i]...Sound trumpets! Every trumpet in the host! / Sixty thousand, on these words, sound, so high the mountains sound, and the valleys resound.</i] (The Song of Roland)