Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

does directory contain documents?

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
Hello all,

I have a process that needs to run if a specific number of days have passed since an event. So, if the mailed date is 15 days ago, I generate a reminder letter, save all the letters to a directory and inform the user that letters are ready to be printed (have to be on letterhead, that's why the delay rather than just printed). But I only want to run the process once no matter how many users sign on, it should only run if it's the 15th day AND it hasn't already run. I figured that if I check the directory where the documents are saved to see if they already exist then I could decide if the process needs to be run. Is there a better way to only have the process run once on the 15th day? If I do need to check the directory for existing files, how do I do that? Thanks!

Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
OK - problem has changed. I have added a field to the database that will be set if the process has already been complete. Now however, I need to be able to print all the documents in the directory. Don't need to see the list or anything, just look in the directory and print everything in it. Any suggestions? Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
I edited this a little here on the website to remove unnecessary references, so I hope it still compiles.
This will retrieve a passed in stringlist with file names. I guess it depends on what you're trying to print as to how you print it from there. Hope this helps.


function GetDirFileNames(const ARootDir : String; var AFileNames : TStringList; AFileExtension : String) : Boolean;
var
LSearchRec : TSearchRec;
LErc : Integer;
begin
Result := False;
If not DirectoryExists(ARootDir) then
Exit;

AFileNames.Clear;
ChDir(ARootDir);
if AFileExtension = '' then
FindFirst('*.*', faAnyFile, LSearchRec)
else
FindFirst('*.' + AFileExtension, faAnyFile,LSearchRec);
LErc := 0;
while LErc = 0 do
begin
if ((LSearchRec.Name <> '.' ) and
(LSearchRec.Name<> '..')) then
begin
if (LSearchRec.Attr and faDirectory>0) then
//
else
if LSearchRec.Name <> '' Then
AFileNames.Add(LSearchRec.Name);
end;
LErc := FindNext(LSearchRec);
end;
if AFileNames.Count > 0 then
Result := True;
end;
 
Thanks for the code! I got it to work! Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top