• 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: When can you use the 'whose' clause (Filter)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When can you use the 'whose' clause (Filter)


  • Subject: Re: When can you use the 'whose' clause (Filter)
  • From: Jerry Krinock <email@hidden>
  • Date: Fri, 11 Apr 2008 15:47:19 -0700

Well, this certainly has been surprising.

Below is my 'whose' tutorial which I believe will guide me in future projects. I don't yet have a 100% understanding of every reason for every failure, but I do believe I can write working scripts from now on.

Thanks for all the help.

Jerry

(* Purpose: Since AppleScript references have to translate back and
   forth between many objects before getting a result, filtering
   lists by searching in a loop can be very slow.  We therefore
   like to use the filter form 'whose', (or equivalently 'where' or
   'that') whenever possible.  But it's a little tricky since this
   filter can only specify application objects.  The following demo
   shows four failed and one successful attempt at using 'whose'. *)

tell application "Xcode"
    -- projects are an element of the application:
    set theProject to project 1
    -- targets are elements of projects:
    set theTarget to target 1 of theProject
    -- build configurations are elements of targets
    set buildConfigs to build configurations of theTarget

    -- Get desired build configuration  (5 attempts follow)

    -- This makes a "can't get" error because buildConfigs
    --   is a free-standing list and does not know that it contains
    --   application objects.
    --set aBC to item 1 of buildConfigs whose name is "Release"

-- And this makes a "can't get" error for the same reason. It
-- does not help that I give it a clue that it contains that
-- the list contains 'build configuration' objects
--set aBC to build configuration 1 of buildConfigs whose name is "Release"


    -- And this makes a "can't get" error because the free-standing
    --   list buildConfigs does not do 'whose'
    --set buildConfigs to build configurations of theTarget
    --tell buildConfigs to set aBC to item whose name is "Release"

-- And this makes a "can't get" error because 'whose' must always
-- operate upon a list and return a list
--tell theTarget to set aBC to build configuration whose name is "Release"


-- But if you add an 's', and then take the 'first' element of the 'whose'
-- output (there is only 1 anyhow), it works. Thanks, Michelle Steiner.
tell theTarget to set aBC to first build configuration whose name is "Release"


    log class of aBC & " " & name of aBC & " " & id of aBC as text
end tell

-- Finally, for that perly urge, do it all in one line

tell application "Xcode" to set aBC to first build configuration of target 1 of project 1 whose name is "Release"

log class of aBC & " " & name of aBC & " " & id of aBC as text

_______________________________________________
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
References: 
 >Re: When can you use the 'whose' clause (Filter) (From: "Stockly, Ed" <email@hidden>)
 >Re: When can you use the 'whose' clause (Filter) (From: Jerry Krinock <email@hidden>)
 >Re: When can you use the 'whose' clause (Filter) (From: Philip Aker <email@hidden>)
 >Re: When can you use the 'whose' clause (Filter) (From: Michelle Steiner <email@hidden>)
 >Re: When can you use the 'whose' clause (Filter) (From: Philip Aker <email@hidden>)

  • Prev by Date: Re: Scripts works with OSX 10.5 but not earlier because of Unicode
  • Next by Date: Re: Scripts works with OSX 10.5 but not earlier because of Unicode
  • Previous by thread: Re: When can you use the 'whose' clause (Filter)
  • Next by thread: Re: When can you use the 'whose' clause (Filter)
  • Index(es):
    • Date
    • Thread