Droplet decreases speed of script dramatically

I have a script that analyzes a csv file, creates lists of information for each column, then imports that info into a filemaker database (each row of info being a record). It also performs a search of a related database before then moving onto the next record.

If I run the script as a script, and choose the excel file, each record processes within a second.

If I alter the script to be a droplet, the script slows down to a crawl and takes approximately 10+ seconds to processes each record.

Is this kind of slowdown a known issue with droplets?

I can’t say if it’s the cause of the problem in your case, but script applications which send a lot of commands to other applications tend to run slowly because it takes a comparatively long time for commands to pass between applications and for the acknowledgements to get back. A droplet is of course an application and presumably yours is sending commands to Filemaker and waiting for Filemaker to acknowledge the completion of each one before continuing.

One workround is to put the code aimed at the other application(s) into a script object and run that with ‘run script’. So instead of .

on open theItems
	repeat with thisItem in theItems
		-- Your code here.
	end repeat
end open

. we use something like:

on open theItems
	run script o with parameters theItems
end open

script o
	on run theItems
		repeat with thisItem in theItems
			-- Your code here.
		end repeat
	end run
end script

‘run script’ is a command in the StandardAdditions OSAX, so I imagine the slight speed advantage must be because communications between OSAXen and applications are faster than those between applications.

I’m not sure if this will improve things for you, but it’s worth a try.

Another option is to put the Applescript into a FileMaker global text field and use the FM script step “Perform Applescript”. (When doing this you would normally comment out the “tell FileMaker Pro” and corresponding “end tell” lines.)

Browser: Safari 531.21.10
Operating System: Mac OS X (10.5)

It does seem like it is worth a try…

And, I set it up just like you did above. (Below is the code copied directly from my script:


on open theItems
	run script o with parameters theItems
end open


script o
	on run theItems
--lots of stuff
end script

But, upon running, I get an error that the variable o is not defined. ?

Hmm. Sorry. I thought it worked when I tested it, but I’m getting the same error myself now. I think it’s a compiler thing. Try putting the script statement before the handler:

script o
	on run theItems
		repeat with thisItem in theItems
			-- Your code here.
		end repeat
	end run
end script

on open theItems
	run script o with parameters theItems
end open

Not a problem, at all.

Thanks for the help! That script ran at just about the same speed as when it is run from Script Editor. AWESOME!

:smiley: