• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: on idle() handler in script object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: on idle() handler in script object


  • Subject: Re: on idle() handler in script object
  • From: Simon Forster <email@hidden>
  • Date: Fri, 26 Aug 2005 11:02:04 +0100


On 25 Aug 2005, at 21:05, has wrote:

That's what I'd do, though I'd probably punt the monitoring part out of the folder action script and into a stay-open applet. You don't really need anything fancy. Something like:

property _kDelay : 2
property _jobQueue : {}

on idle
    repeat with oRef in _jobQueue
        oRef's process() returning isFinished
        if isFinished then set oRef's contents to missing value
    end repeat
    set _jobQueue to _jobQueue's scripts
    return _kDelay
end idle

on addJob(theFile)
    script
        property _file : theFile
        property _previousSize : 0

        on process()
            set currentSize to size of (info for _file)
            set isFinished to currentSize is _previousSize
            if isFinished then
                --perform backup and write to log
            else
                set _previousSize to currentSize
            end if
            return isFinished
        end process
    end script
    set end of _jobQueue to result
end addJob

The folder action script then calls the applet's addJob handler for each file to be processed.

That's the sort of thing - although your code is far more concise than anything I'd write - I'll be digesting and learning. Last time I did this sort of thing I had the folder action handler in the main (stay-open) applet. When the folder action was poked, it added the script object to the global queue. Seemed to work quite well.


If you split the stuff out into two separate scripts, how do you pass the reference across to the stay-open applet. IIRC, you can't pass arguments between applescript applets.

Thanks for the pointers so far.

ATB

Simon Forster
_____________________________________________________
 LDML Ltd, 62 Pall Mall, London, SW1Y 5HZ, UK
 Tel: +44 (0)70 9230 5244   Fax: +44 (0)70 9230 5247
_____________________________________________________

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: on idle() handler in script object (From: has <email@hidden>)

  • Prev by Date: Re: Scripting Addition for mouse operations.
  • Next by Date: What happened to date in Tiger??
  • Previous by thread: Re: on idle() handler in script object
  • Next by thread: Re: on idle() handler in script object
  • Index(es):
    • Date
    • Thread