• 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: Getting record items of a sublist
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting record items of a sublist


  • Subject: Re: Getting record items of a sublist
  • From: Shane Stanley <email@hidden>
  • Date: Sun, 30 Oct 2011 09:27:31 +1100

On 30/10/2011, at 6:22 AM, Ronald Hofmann wrote:

yes, my list can become pretty big and I think that something like
myname of theNameList would be faster than a loop.

You may be right, but one of the biggest mistakes you can make in AS (and elsewhere) is to guess what will be fastest, especially if there are no events involved.

FWIW, what you want to do is simple enough using AppleScriptObjC:

-- make the list an array
set theNameList to current application's NSArray's arrayWithArray_(theNameList)
-- get the myname values
return theNameList's valueForKey_("myname")

And if you're happy to use ASObjC Runner, you can call it from a vanilla AS script like this:

script extractProperty
set {theList, theKey} to current application's NSApp's passedValue() as list
set theList to current application's NSArray's arrayWithArray_(theList)
return theList's valueForKey_(theKey)
end script

tell application "ASObjC Runner" to set theResult to run the script {extractProperty} passing {theNameList, "myname"} with result returned

But my admittedly minimal tests suggest that a loop is likely to be as fast as using ASObjC Runner unless the list gets very large (using AppleScriptObjC itself would be much faster).

-- 
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Getting record items of a sublist
      • From: wayne melrose <email@hidden>
References: 
 >Fwd: Getting record items of a sublist (From: Ronald Hofmann <email@hidden>)

  • Prev by Date: Backing up SD Prefs & Applescript Font Prefs
  • Next by Date: Re: Getting record items of a sublist
  • Previous by thread: Re: Getting record items of a sublist
  • Next by thread: Re: Getting record items of a sublist
  • Index(es):
    • Date
    • Thread