• 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: Procedure Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Procedure Problem


  • Subject: Re: Procedure Problem
  • From: Andrew Oliver <email@hidden>
  • Date: Tue, 11 Mar 2003 08:18:26 -0800

You get the error because you're no longer targeting Address Book in the
'set_a_vars' procedure.

aCard is a reference to a person - if you look at it in the Script Editor
you'll see something like

aCard --> person id "21D949C5-BB19-12D6-9603-003061D30836:ABPerson" of
application "Address Book"

Since you're no longer in a 'tell application "Address Book"' block,
AppleScript has no way of determining what a 'phone' of 'person id blah blah
blah' is.

To fix it, either change set_a_vars to include a tell application "Address
Book" block, or extract the phone numbers in your primary tell block rather
that in a subroutine.

Andrew
:)


On 3/11/03 6:45 AM, "Darwin Zins" <email@hidden> wrote:

> Can anyone tell me why I can't do this:
>
> tell application "Address Book"
> repeat with aPerson in every person
> my set_a_vars(aPerson)
> end repeat
> end tell
>
> on set_a_vars(aCard)
> repeat with aPhone in (every phone of aCard)
> tell aPhone
> set phoneLabel to (get the label as Unicode text)
> if phoneLabel is equal to "home" then
> set a_home_phone to (get the value as Unicode text)
> else if phoneLabel is equal to "mobile" then
> set a_home_mobile to (get the value as Unicode text)
> else if phoneLabel is equal to "home fax" then
> set a_home_fax to (get the value as Unicode text)
> else if phoneLabel is equal to "work" then
> set a_business_phone to (get the value as Unicode text)
> else if phoneLabel is equal to "work fax" then
> set a_business_fax to (get the value as Unicode text)
> end if
> end tell
> end repeat
> end set_a_vars
>
> I get an error: "Expected class name but found identifier." and it
> highlights phone in the (every pphone of aCard).
>
> Also, the code that I was looking at does the get the value as Unicode
> text, do I really need the as Unicode text part?
>
> Thanks,
>
> Darwin
> _______________________________________________
> applescript-users mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/applescript-users
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Procedure Problem (From: Darwin Zins <email@hidden>)

  • Prev by Date: Re: Procedure Problem
  • Next by Date: Need help scripting System Prefs (Sound, Displays)
  • Previous by thread: Re: Procedure Problem
  • Next by thread: Re: Procedure Problem
  • Index(es):
    • Date
    • Thread