wait for file to be created

Does anyone know how to have a script wait until a file exists?
Basically I have a script that generates an export from Filemaker as a text file, and I want to then take that text file and manipulate it in BBEdit.
It doesn’t take too long (maybe 10 seconds max) but the script proceeds without waiting for the export to finish.
Anyone have any ideas? I’m thinking some kind of loop but I don’t know what to do. Thanks folks.

Have you tried DELAY?
mg

: Does anyone know how to have a script wait until a file
: exists?
: Basically I have a script that generates an export from
: Filemaker as a text file, and I want to then take that
: text file and manipulate it in BBEdit.
: It doesn’t take too long (maybe 10 seconds max) but the
: script proceeds without waiting for the export to
: finish.
: Anyone have any ideas? I’m thinking some kind of loop but
: I don’t know what to do. Thanks folks.
If you don’t mind using an OSAX you have many options. I use Akua Sweets mostly because it can do so many things; over 120 additions.
The code might look like this:

repeat
if (the kind of entry in 'the folder to look in' named "whatever") does not equal nothing then exit repeat
end repeat

That should do what you want. Any other code for processing the file should go after that snippet.

: Does anyone know how to have a script wait until a file
: exists?
: Basically I have a script that generates an export from
: Filemaker as a text file, and I want to then take that
: text file and manipulate it in BBEdit.
: It doesn’t take too long (maybe 10 seconds max) but the
: script proceeds without waiting for the export to
: finish.
: Anyone have any ideas? I’m thinking some kind of loop but
: I don’t know what to do. Thanks folks.
Hi,
I don’t know if you are a novice or not, but here is a construct I use frequently. This assumes the BBEdit operations on the text file are driven by AppleScript (your script).
In this fashion you must write in this way:
first make the handler to drive BBEdit:

on manipulateTextFile(textFilePath)
	tell application "BBEdit"
		--do the job with the text file
		--save the text file (if you save a new text file provide the path)
	end tell
	return "done" --(or wathever, or the path to the new file)
end manipulateTextFile

now the waiting handler

on myHandler()
	--do action
	--do action
	--do action
	set theNewFilePath to (my manipulateTextFile(textFilePath))
	--do action
	--do action
end myHandler

this way the handler “myHandler()” waits the BBEdit ends the job and write the file, and the handler “manipulateTextFile(textFilePath)” returns the data (the new file path or just “done” or wathever) then it continue their actions without problems.
hope this help
Roberto

Try the Wait Application addition. Works for some types of situations very well. The delay command seems to often just pause everything for a while. Or is that my imagination. I just don’t here any clicking from the hard drive when I use a delay command!
: Does anyone know how to have a script wait until a file
: exists?
: Basically I have a script that generates an export from
: Filemaker as a text file, and I want to then take that
: text file and manipulate it in BBEdit.
: It doesn’t take too long (maybe 10 seconds max) but the
: script proceeds without waiting for the export to
: finish.
: Anyone have any ideas? I’m thinking some kind of loop but
: I don’t know what to do. Thanks folks.

Does this work with any application or just ones that can function as a background process? It’s a unique solution nonetheless.
: If you don’t mind using an OSAX you have many options. I
: use Akua Sweets mostly because it can do so many
: things; over 120 additions.
: The code might look like this: repeat
: if (the kind of entry in ‘the folder to look in’ named
: “whatever”) does not equal nothing then exit
: repeat
: end repeat
: That should do what you want. Any other code for
: processing the file should go after that snippet.

call your applescript (send apple event script step) after the export script step in FileMaker