• 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: Bug with "missing value"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug with "missing value"


  • Subject: Re: Bug with "missing value"
  • From: Paul Berkowitz <email@hidden>
  • Date: Mon, 13 Jun 2005 16:16:06 -0700
  • Thread-topic: Bug with "missing value"

Title: Re: Bug with "missing value"
On 6/13/05 3:07 PM, "David Crowe" <email@hidden> wrote:


I have a list of fields from the AddressBook, let's call it "x".


The following code does not find any matches with the constant 'missing value':

                           repeat with aField in x
                                   if aField = missing value then
                                         set end of thePerson to ""
                                 else
                                     set end of thePerson to aField
                                   end if
                           end repeat


But if I change it to:

                            repeat with i from 1 to (count x)
                                  if item i of x = missing value then
                                      set thePerson to thePerson & {""}
                                  else
                                     set end of thePerson to item i of x
                                end if
                      end repeat

Then it works.

I have a workaround, so a solution is just a matter of interest, but this does seem wierd to me. Perhaps one of the AppleScript gurus on the list can discuss the subtlety that I've bumped into.


What's x, for goodness sake? Just a list? This is a very well known issue with list items, whereby the 'repeat with anItem in aList' produces not the resolved item but a reference to it, which does not meet the rigorous equality test, and so fails, whereas your second method resolves the reference first, so succeeds. The other way to resolve them are via 'contents of':

                               repeat with aField in x
                                  if contents of aField = missing value then
                                         set end of thePerson to ""
                                 else
                                     set end of thePerson to contents of aField
                                   end if
                           end repeat

This is in the AppleScript Language Guide. It's not necessary to do this when not using "=" or "≠" as the comparison operator, but it's hard to remember that.

Personally, I always use your second method, which always works, to avoid these problems.


--
Paul Berkowitz
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Bug with "missing value" (From: David Crowe <email@hidden>)

  • Prev by Date: crop left half of image via script
  • Next by Date: Re: OT: Re: it's all true
  • Previous by thread: Bug with "missing value"
  • Next by thread: crop left half of image via script
  • Index(es):
    • Date
    • Thread