Link to home
Start Free TrialLog in
Avatar of kwaing
kwaing

asked on

Lotus Script to be excute only after an exe program ended...

HI I am having much headach with this, I've very new to lotus script . I have a VB program which create files inside a temp folder inside the c:\ and what the lotus script needs to do is. Create an agent that call my exe program then after the program ends get the files that the exe created inside the temp folder and attach it to the new memo that the user have already created.

 I have tried the Yeild function and apparently the win3.1 API doesn't support the w2k and its a big mess here. Please help.

Below is my code. What its doing now is it doesn't wait untill the shell program ends, the message box pops up imideately when the program is called and I don't want it that way. Msg box is my temporarily solution to halt the script.

Sub Initialize
      
      Dim session As New NotesSession
      Dim curdb As NotesDatabase
      Dim workspace As New NotesUIWorkspace
      Dim rtitem As NotesRichTextItem
      Dim object As NotesEmbeddedObject
      Dim chk As Boolean
      Dim result As Integer
      result = Shell ( "C:\test.exe", 1)
      
      Msgbox "Please click on OK when you have selected the Documents to be Attached."
      
      Set curdb = session.CurrentDatabase
      Dim doc As New NotesDocument (curdb)
      Set rtitem = doc.CreateRichTextItem( "Body" )      
      Dim pathName As String, fileName As String
      pathName$ = "C:\Temp\"
      fileName$ = Dir$(pathName$, 0)
      Do While fileName$ <> ""
            Msgbox fileName$
            Set object = rtitem.EmbedObject( EMBED_ATTACHMENT, "",pathName$&fileName$ )            
            Kill pathName$&fileName$            
            fileName$ = Dir$()
      Loop
      doc.Form = "Memo"      
      Call doc.save (True, True)
      Call workspace.EditDocument(True, doc)      
End Sub
Avatar of CRAK
CRAK
Flag of Netherlands image

From Designer help:

...
After Shell starts a program, LotusScript continues to execute the script without waiting to make sure the program has completed. You cannot be sure that a program started by Shell has finished running before the rest of your script is executed.
...

Do you have the VB source code?
In that case, can you make it to create some kind of a trigger file when it is done?
LS yould wait in a loop until that file if found (and delete it).
The rest of the code is then allowed to execute.
ASKER CERTIFIED SOLUTION
Avatar of kwaing
kwaing

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for sharing that! It's certainly worth bookmarking!
Do realize that you restrict yourself to certain versions of Windows only!

In Win 3.x I once had to use Windows' OpenFile dialog. Can't remember the DLL it came from or other details, but it had the limitation of being unable to run on a vast no. of clients (running OS/2).
Later, when Win 3.x was replaced with Win2000 (Y2K related upgrade), we needed to rewrite the code again, as the DLL changed.
Since then, I generally prefer the implementation of cross-platform solutions, just like Notes itself is. A trigger file can provide just that, although is kind of a silly way to control a program.

So you've solved it yourself. Well done!
You do need to finalize the question though.... If you post a link under community support, you can ask to close it for you and refund the points.
I have become Page Editor for this topic area.
If you like I could close this question for you and refund your points.

Thanks!

CRAK
Page Editor
Avatar of kwaing
kwaing

ASKER

Thank you CRAK,

I wasn't really sure how to request for the closing of this topic.

Please do so.

Thanks!!
K.
Question closed with user's consent; points (50) refunded.

CRAK
Page Editor