• 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: Can someone explain this?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can someone explain this?


  • Subject: Re: Can someone explain this?
  • From: "email@hidden" <email@hidden>
  • Date: Sun, 15 Mar 2009 10:04:16 -0700


As previously noted, the only documented exception for the non- optionality of 'the' is 'the clipboard' and all other documented usage is optional. All in all, I think it would be better if 'the clipboard' migrated to 'pasteboard' and 'the' is always optional. Then there will be zero exceptions to remember and more time to concentrate on the scripting task at hand.

That is not accurate. The "the" is optional. The command works just fine without it, it is not required, so it is optional. The issue is that using it changes the behavior of the command in an unexpected way. There are many cases where inserting the word "the" will interfere with a command.


choose file
choose the file

One compiles and one doesn't. This case is very much the same. "end of [a list]" is the command used to get the value of the last item of the list, but in Michelle's script she was using it to provide an index for the last item. It's kind of cool it works that way at all and when it doesn't work it's usually pretty clear, but if the list is formatted this way:

set myList to {"a", "b", "c", pi as text, 3}
items 1 through the end of myList

The command compiles and runs without an error but provides an incorrect result. So, in my book, that makes it a bug.

The work around is to use "-1" rather than 'the end" for index. For example:

This syntax:

items 2 through last item  of myList

Compiles as this:

items 2 through -1 of myList

But this syntax:

items 2 through the last item of myList

Compiles as is, but has the same behavior at runtime as Michelle's version.



ES

_______________________________________________
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: Can someone explain this?
      • From: Bruce Brown <email@hidden>
References: 
 >Re: Can someone explain this? (From: "Nigel Garvey" <email@hidden>)
 >Re: Can someone explain this? (From: Philip Aker <email@hidden>)

  • Prev by Date: Re: Can someone explain this?
  • Next by Date: Working SOAP currency exchange rate server?
  • Previous by thread: Re: Can someone explain this?
  • Next by thread: Re: Can someone explain this?
  • Index(es):
    • Date
    • Thread