Pass variable between applets

I don’t know where the 0 comes from. The value should either be a list of HFS paths or ‘missing value’.

The watcher script’s designed to be launched by the main script and to quit itself when there are no more running clone applications to be watched. There’s a safety net of one idle so that it doesn’t quit before the main script’s had a chance to pass it the first application path. It may be that this isn’t enough if it takes the main script more than about 5 seconds to execute the setServer() handler, duplicate and launch the application to be watched, and pass its path the watcher app. The simplest thing to try would be to move the launch of the watcher app to after the launch of the clone app — so that, in the main script, the main() handler looks like this:

on main()
	set zOpenClientsFolder to zOpenClientsPath as POSIX file as alias
	
	-- Find an untaken name to use for the next GenericEndive.app clone.
	tell application "Finder" to set existingZClientNames to name of zOpenClientsFolder's application files
	set n to 1
	set EndiveAppName to "EndiveName" & n & ".app"
	repeat while (existingZClientNames contains EndiveAppName)
		set n to n + 1
		set EndiveAppName to "EndiveName" & n & ".app"
	end repeat
	
	-- Duplicate GenericEndive.app, rename the duplicate, and get the HFS path to it.
	tell application "Finder" to set name of (duplicate application file GenericEndiveName of zOpenClientsFolder) to EndiveAppName
	set EndiveAppPath to ((zOpenClientsFolder as text) & EndiveAppName & ":")
	
	-- Set up the server "database" in the duplicate's bundle.
	setServer(EndiveAppPath)
	
	-- Set the duplicate app going.
	tell application EndiveAppPath to activate
	
	-- Once it's going, make sure the stay-open watcher application's running.
	set watcherPath to ((zOpenClientsFolder as text) & watcherName & ":")
	tell application watcherPath
		if (not running) then run
	end tell
	
	-- Pass the watcher app the path to the cloned app.
	tell application watcherPath to addApp(EndiveAppPath)
end main

You mean apart from waiting for three weeks, until I’d forgotten what the scripts were supposed to do and had deleted all my test files and folders, before providing any feedback? :wink:

watchAppPaths should be populated with the correct apps’ HFS paths, in which context the trailing colons are intentional and correct.