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

Having a program wait for a file to be ready to write to it....

Status
Not open for further replies.

Regression

IS-IT--Management
Oct 10, 2002
17
US
Hello All,

I am writing a program that writes a line of text to a text file. I have another program(3rd Party) that checks the text file for the entered line of text. It then executes a process based on the text it finds in the text file.

The problem I am having is that my program must write to the file wait for the other program to read the file and execute its processes then clear the file.

My question for you all is is there a way to make my vb program wait until the file is not locked by the other process to open it and clear the file?

Private Sub Command1_Click()
Dim Tmp As String
Tmp = Text1.Text
Open "C:\testing.txt" For Output As #1
Print #1, Tmp
Close #1
Sleep (500)
Text1.Text = ""
Tmp = Text1.Text
Open "C:\testing.txt" For Output As #1
Print #1, Tmp
Close #1
End Sub

The code I am working with looks like this.

Private Sub Command1_Click()
Dim Tmp As String
Tmp = Text1.Text
Open "C:\testing.txt" For Output As #1
Print #1, Tmp
Close #1
' I would like to eliminate this time pause for a wait for file ready pause.
Sleep (500)
Text1.Text = ""
Tmp = Text1.Text
Open "C:\testing.txt" For Output As #1
Print #1, Tmp
Close #1
End Sub

Thanks
 
A bit of a low tech solution, but maybe the 1st program could create a "trigger" file. The creation of this fie tells the other program that it can proceed.

Hope it helps...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top