• 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: lists and items and position of items
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lists and items and position of items


  • Subject: Re: lists and items and position of items
  • From: kai <email@hidden>
  • Date: Sat, 12 Mar 2005 14:52:50 +0000


On Sat, 12 Mar 2005 14:43:59 +0100, Christian Vinaa wrote:

just to close this question;

Yvan pointed out the correct solution now it works ok

Almost... ;-)

For the benefit of those not familiar with this issue, Christian's script was comparing strings like "Sal" with the references like: "Carl"}. While we might recognise these as having essentially similar meanings, they differ nevertheless - unless and until the reference is evaluated to an exact match, such as (in this case): "Sal". Christian's 'list-position' handler therefore found zero matches in every comparison.

If I remember correctly, yvan suggested coercing the reference to a string before making the comparison. Indeed, that works fine for the list of strings that Christian was using as a source - specifically:

----------

{"Sal", "Sue", "Bob", "Carl"}
...
requires a coercion like this in the 'list_position' handler:
i
...
> {1, 2, 3, 4}

----------

It obviously follows that, if we use a specific coercion for dereferencing, it should reflect the class of the original items. For example:

----------

{45, 3.624, 67, 9 2}
...
i
...
> {1, 2, 3, 4}

----------

{, }
...
i
...
> {1, 2}

----------

{{3, 4, 5}, {"x", "y", "z"}, {, }, {current date
...
i
...
> {1, 2, 3, 4}

----------

...and so on.

However, a much more versatile, general-purpose approach to dereferencing is to either coerce to item, or to get the contents of each reference. These methods are even more useful when a list of mixed classes might be involved:

----------

{, "Sal", current date, {"x", "y", "z"}, , 86, {", "}, , 2 ^ 5, }
...
i
or:
i

...
> {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

----------

---
kai
 _______________________________________________
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

  • Follow-Ups:
    • Re: lists and items and position of items
      • From: kai <email@hidden>
  • Prev by Date: Re: lists and items and position of items
  • Next by Date: Re: lists and items and position of items
  • Previous by thread: Re: lists and items and position of items
  • Next by thread: Re: lists and items and position of items
  • Index(es):
    • Date
    • Thread