| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
I want to create a list of items, eg. a list of numbers from 5000 to -5000. In Script Editor I can run the script:
<x-tad-smaller>set</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>myList</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> {}
</x-tad-smaller><x-tad-smaller>repeat</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>with</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>n</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>from</x-tad-smaller><x-tad-smaller> 1 </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> 10000
</x-tad-smaller><x-tad-smaller>set</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>end</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>of</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>myList</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> 5000 - </x-tad-smaller><x-tad-smaller>n </x-tad-smaller><x-tad-smaller>--</x-tad-smaller><x-tad-smaller>SLOW!!</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>end</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>repeat</x-tad-smaller><x-tad-smaller>
</x-tad-smaller>
Unfortunately, this is slow (about 30 seconds on my Powerbook G4 1.5 GHz). A much faster method is:
<x-tad-smaller>set</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>myList</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> {}
</x-tad-smaller><x-tad-smaller>set</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>myListRef</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>a reference</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>myList</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>repeat</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>with</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>n</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>from</x-tad-smaller><x-tad-smaller> 1 </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> 10000
</x-tad-smaller><x-tad-smaller>set</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>end</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>of</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>myListRef</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>to</x-tad-smaller><x-tad-smaller> 5000 - </x-tad-smaller><x-tad-smaller>n </x-tad-smaller><x-tad-smaller>--</x-tad-smaller><x-tad-smaller>FAST!!</x-tad-smaller><x-tad-smaller>
</x-tad-smaller><x-tad-smaller>end</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>repeat
</x-tad-smaller>
This takes less than a second when run in Script Editor.
Unfortunately, the second script will not work in an Applescript Studio project. The loop produces the "NSCannotCreateScriptCommandError (10)". The first script runs fine in Applescript Studio, but once again, takes about 30 seconds to complete.
How can I create the equivalent of the second script in Applescript Studio? Or more generally, what is the fastest method of appending to a list in Applescript Studio, given that effective methods that work in Script Editor don't necessarily work in A.S.?
Many thanks,
Martin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden
This email sent to email@hidden
_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-studio mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-studio/email@hidden This email sent to email@hidden
| References: | |
| >Fastest Method to Append to a List (From: Martin Fuhrer <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.