realbasic-nug
[Top] [All Lists]

Re: Looping, threads and Applescript

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Looping, threads and Applescript
From: Eric Williams <eric at oxalyn dot com>
Date: Thu, 31 Jan 2008 14:18:58 -0800
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <AF0A2437-ABE6-4AA5-BA42-B15D73D33A8E at comcast dot net> <50D1C276-EA47-4206-97CE-7244FEB51A2B at sentman dot com>
On Jan 31, 2008, at 1:41 PM, James Sentman wrote:

>> Hi All,
>> I wonder if I can get some insight and input for the following
>> problem. I have written an App that parses Mail for Duplicates. It
>> works very well ( thanks to help from this list vis-a-vis threads and
>> timers).
>>
>> Next issue regards another approach. It is possible to use  
>> AppleScript
>> in a loop to move e-mails within Mail. But the loop seems to  
>> "outpace"
>> Mail's ability to respond, or perhaps AppleScript ability to help. So
>> has anyone else experienced this. If so, can one "Slow down" the  
>> loop?
>> Perhaps feedback from Mail that an action has occured.
>>
>
> An applescript should wait for the app being scripted to finish the
> command before moving onto the next command. Unless you have it in a
> loop of "ignoring application responses" in which case it will just
> queue up the events as fast as possible and give the app a heart  
> attack.
>
> Another possibility is to not do the loop in applescript at all but
> just a single move. And then call the script repeatedly with the new
> data each time from your RB app. That will also give you the
> opportunity to cancel it by being able to check again for the user
> cancelled value between each one too.

This will make the system more "cancel-able" at the expense of  
performance - it seems like it's a lot of work for the system to  
execute an AppleScript, and calling one repeatedly is much more  
costly than writing the loop itself in AppleScript.

Perhaps you could break the loop down into smaller chunks that are  
not actually atomic - for example, instead of having AppleScript loop  
through 1,000 items, or calling the script 1,000 times, have the  
script process 100 items and then return back to your application.

Eric Williams
Oxalyn Software
http://software.oxalyn.com/

AE Monitor
http://software.oxalyn.com/AEMonitor/


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>