Hello
From presumedly your messages in the mailing-list such as :
http://lists.apple.com/archives/applescript-users/2010/Jun/msg00292.html
I'd surmise that you're saying the code below works :
--SCRIPT1
property tvpi2crontabP : "/DVR/scripts/tvpi2crontab.app"
property tvpi2crontab : (load script POSIX file tvpi2crontabP) -- loaded script object
tvpi2crontab's init()
tvpi2crontab's getEtvList()
--END OF SCRIPT1
whereas the code below fails (i.e., hangs midway) :
--SCRIPT2
property tvpi2crontabP : "/DVR/scripts/tvpi2crontab.app"
property tvpi2crontab : application (POSIX file tvpi2crontabP) -- external stay-open applet
tvpi2crontab's init()
tvpi2crontab's getEtvList()
--END OF SCRIPT2
given the tvpi2crobtab contains code like (partially) :
--SCRIPT SERVER (part)
script etvProgram
property parent : tvpiProgram
property UID : missing value
end script
global etvList
on init()
--omitted
end init
on getEtvList()
set etvList to {} -- global
tell application "EyeTV"
with timeout of 3 seconds
set tempList to every program whose start time > now or enabled is false
repeat with etvp in tempList
set eid to etvp's unique ID as integer
copy etvProgram to etvSched
copy eid to etvSched's UID
set end of etvList to etvSched
end repeat
end timeout
end tell
end getEtvList
--END OF SCRIPT SERVER (part)
---
I recently posted an analysis and possible solutions for similar issue in Numbers forum.
Topic : Why this AppleScript don't work?
http://discussions.apple.com/thread.jspa?threadID=2474924
http://discussions.apple.com/message.jspa?messageID=11768697#11768697
http://discussions.apple.com/message.jspa?messageID=11769489#11769489
http://discussions.apple.com/message.jspa?messageID=11794477#11794477
(The last post of mine contains the most precise notes, I hope.
Some comments in my other posts regarding the cause of the issue are incorrect and should be revised as those in the last one.)
Based on the analysis, your SCRIPT SERVER will eventually become unresponsive when run with 'etvList' not being local. Also it may eventually cause stack overflow when run with 'etvSched not being local.
Solutions would be a) to declare local for these variables, or b) not to copy an existing script object but use constructor to make new script object.
The reason why this problem does not occur in SCRIPT1 using 'load script' command but in SCRIPT2 using stay-open applet would be that :
1) by using 'load script' command, the global context as is defined in the script object which is loaded by the command does not come in global context at run-time (that is global context as is seen in container application running the script); and
2) by using stay-open applet, the global context as is defined in the script in applet becomes the global context at run-time because the container application is the applet itself.
Thus only the applet version is affected by the recursive deep copy of global context at run-time which is included in script object as its closure.
*It is not the issue of whether the code is run in applet or Script Editor, but the issue of whether the code is loaded to container application by 'load script' command or not.
E.g., if you add the following run handler to the above SCRIPT SERVER and run it in Script Editor, it will hang as SCRIPT2 does.
on run
init()
getEtvList()
end run
Hope this may be of some help,
H