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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timing issue 1

Status
Not open for further replies.

oscarse

Programmer
Apr 9, 2006
99
CA
Situation ... I have an external file mangler that runs from a shell commandline ... I have a function that calls this;

public function fileMangler(strFile as string) as boolean

dim fs
set fs = createobject("Scripting.FileSystemObject")

if fs.fileexists(strFile) then
if 0 = shell(g_str_mangler & " " & strfile) then goto fm_err
loErr = doevents
loerr = doevents
endif
filemangler = false
exit function
fm_err:
filemangler = true
end function

I then have a function that calls this

if filemangler(g_str_file1) then goto err1
loErr = doevents
loErr = doevents
if filemangler(g_str_file2) then goto err2
loErr = doevents
loErr = doevents


At issue is the first instance of filemangler hasn't finished so when the second istance runs it appears to be confused ... this is a third party program so expect its not reentrant ... is there a better way to ensure external calls are complete before allowing the program to continue?
 
What about this ?
Code:
Public Function fileMangler(strFile As String) As Boolean
Dim fs As Object, sh As Object
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(strFile) Then
  Set sh = CreateObject("WScript.Shell")
  fileMangler = sh.Run(g_str_mangler & " " & strfile, 1, True)
  Set sh = Nothing
End If
Set fs = Nothing
End Function

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top