The AccuTerm forum has moved. Go to community.rocketsoftware.com to register for the new Rocket forum. |
See if file exists in Windows Folder |
Post Reply |
Author | |
homerlh
Beta Tester Joined: November 11 2004 Location: United States Status: Offline Points: 288 |
Post Options
Thanks(0)
Posted: March 22 2013 at 5:26am |
I have an application that generates Invoices for emailing and then emails the invoices. I use something called PDF_Creator to generate the invoice and of course I use the sample program here to send email using outlook.
My problem is that I may have to rework the way I do things or else I need a better way to determine when the PDF is actually created. I print the form to the PDF_Creator printer and it will generate the output PDF. It takes this a while to happen. Right now I have a SLEEP 2 in the program after I generate the invoice to wait until I try to send the email. Otherwise, the attachment (the PDF) cannot be found. It works with the SLEEP 2, but on my computer, it worked with a SLEEP 1. Right now I am at the client's AP computer. I am contemplating revising the method and sending all of the invoices to the PDF generator and then trying to email all of them. I attempted to use a script to tell me when the PDF has been created and it subsequently screws up the sending of the email. Something breaks and I don't know what. It's all commented out, but you can still probably follow the code.
Can someone suggest a method to determine when the PDF has been created or am I going to have to rework the sequence of the program to PDF all and then Email all? Thank you, Larry Hazel |
|
palinder
Groupie Joined: June 08 2012 Location: United States Status: Offline Points: 51 |
Post Options
Thanks(0)
|
Larry:
This code should do the trick... SUBROUTINE ACCUTERM.FILE.CHECK(PATH,STAT) * EQU SVM TO CHAR(252) EQU VM TO CHAR(253) EQU AM TO CHAR(254) * * Passed Parameters * * PATH = Full DOS Path to the file to be checked * STAT = Result of the check * 0 - File Not Found * 1 - File Found * Test if file exists using AccuTerm Script * STAT = 0 SCRIPT = '' SCRIPT = 'On Error Resume Next' SCRIPT = SCRIPT:CHAR(25):'X = 0' SCRIPT = SCRIPT:CHAR(25):'X = Abs(FileExists("':PATH:'"))' SCRIPT = SCRIPT:CHAR(25):'InitSession.Output Cstr(X) & Chr$(13)' * PRINT CHAR(27):CHAR(2):'P':SCRIPT:CHAR(13): ECHO OFF INPUT STAT: ECHO ON RETURN END |
|
homerlh
Beta Tester Joined: November 11 2004 Location: United States Status: Offline Points: 288 |
Post Options
Thanks(0)
|
Thanks for the code sample. But it is essentially the same as my code which does let me know when the PDF is there, but breaks the subsequent EMAIL.OUTLOOK call.
|
|
Shrek59
Senior Member Joined: December 04 2006 Location: New Zealand Status: Offline Points: 208 |
Post Options
Thanks(0)
|
Hi Larry,
Maybe there is a timing issue here. Your program is searching to see if an item exists but subsequent processing fails ... perhaps the item isn't actually complete when that processing takes place. I would try moving the SLEEP 1 to be before your test for the item's existence. That may be sufficient to get things working properly - until such time as the system is under a big load and it takes longer than that to generate the PDF. The other thing to try is to get your PDF generation routine to write a "completion item" (e.g. ID.ITEM:'.txt') to the folder, and search for this item rather than the PDF. Once again, timing is important as you need to be sure that the completion item is created AFTER the PDF has finished being generated. HTH, Brian |
|
homerlh
Beta Tester Joined: November 11 2004 Location: United States Status: Offline Points: 288 |
Post Options
Thanks(0)
|
Hi Brian,
Thanks for the suggestion. This code works fine to determine if the file exists, but it screws up the call to OUTLOOK.EMAIL later in the program. If this script is commented out, the OUTLOOK.MAIL works. I just added a sleep 2 to my program to give PDF_Creator time to do its work. I have a big problem with my laptop. I had just typed this entire message - even longer when my hand scraped across the touch pad. Somehow it erased everything. It always happens when I forget to turn off the touchpad. I had totally disabled the touchpad by removing the drivers, but the PC got an update and now I cannot remove the drivers any more. Oh well, thanks again for the suggestion. Larry Hazel |
|
Tim Bristow
Newbie Joined: February 27 2012 Location: United Kingdom Status: Offline Points: 7 |
Post Options
Thanks(0)
|
Hi Larry,
The routine below works for me when checking if a file exists. It uses the native Windows command line for checking. SUBROUTINE LOCAL.FILE.EXISTS(FILE.NAME,EXISTS.FLG) * EXPORT.COPY.CMD = 'IF EXIST "':FILE.NAME:'" (ECHO 1) ELSE (ECHO 0)' SEND.PATH = "" SEND.FILE = "" SEND.DATA = "" GET.PATH = "" GET.FILE = "" GET.DATA = "" EXISTS.FLG = "" CALL DOSSVC(EXPORT.COPY.CMD,SEND.PATH,SEND.FILE,SEND.DATA,GET.PATH,GET.FILE,GET.DATA) EXISTS.FLG = GET.DATA RETURN END Hope this helps. Not sure if it will interfere with your outlook script. Tim |
|
PSchellenbach
Admin Group Moderator Joined: December 15 2003 Location: United States Status: Offline Points: 2150 |
Post Options
Thanks(0)
|
There is a subroutine in the SAMPLES file in the ACCUTERM account to test if a file exists. ATTESTFILE uses a script similar to the one posted here by palinder to check if a file exists. There is a companion subroutine, ATTESTDIR, to test if a directory exists. These have been included with AccuTerm for a long time (at least since 2000). Old versions of AccuTerm used different names (TEST.FILE and TEST.DIR) than the current version.
Thanks, Pete |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |