• 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: More about Records
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More about Records


  • Subject: Re: More about Records
  • From: "Bryan" <email@hidden>
  • Date: Thu, 04 Jan 2001 14:16:46 -0500

In addition:
You can coerce the explicit extraction of the contents by asking for the
value of the contents as a specific class


--------------

set primes to {2,3,5,7,11}
repeat with aPrime in primes
if 7 is (aPrime as integer) then display dialog "Seven is too a prime!"
end repeat


or


set primes to {2,3,5,7,11}
repeat with aPrime in primes
if "7" is (aPrime as text) then display dialog "Seven is too a prime!"
end repeat


----------
>From: email@hidden
>To: email@hidden
>Subject: Re: More about Records
>Date: Thu, Jan 4, 2001, 1:07 PM
>

> On Thu, 4 Jan 2001 11:11:57 +0100, "Serge Belleudy-d'Espinose"
> <email@hidden> suggested,
>
>> At 0:54 -0500 4/01/01, email@hidden wrote:
>>
>> >Its sometimes tricky to see when things are references, since if you ask for
> the class of one, it gets its contents > evaluated. This is related to the
old
> "comparison inside a 'repeat with' loop" problem.
>> >
>> > set primes to {2,3,5,7,11}
>> > repeat with aPrime in primes
>> > if 7 is aPrime then display dialog "Seven is too a prime!"
>> > end repeat
>> >
>> >and you see no dialog. That's because aPrime on the fourth iteration isn't
> 7,
>> >but "item 4 of {2,3,5,7,11}". Because "is" doesn't force the reference to
> spit out its contents, the comparison > becomes a number compared to a
> reference. And if the classes aren't the same, the result is always false.
>>
>> Thank you for making it so clear.
>> I think you should add that it's easy to solve this problem by forcing the
> item to coerce to its real value. With your > example
>>
>> if 8 is (aPrime+1) then display dialog "Seven is too a prime!"
>>
>> will work, as will adding a string to a reference to a string etc.
>
> The universal way to fix this would be to simply realize that aPrime is a
> reference, and to explicitly extract its contents.
>
> if 7 is contents of aPrime then display dialog "Is too! Is too!"
>
> For a further discussion of the difference between contents, references,
values,
> and containers, see "Through the Looking Glass" for the White Knight's
> discussion with Alice about the song "A Sitting on the Gate" (or was it
> "Haddock's Eyes", "The Aged, Aged Man", or ...)
> --
> Scott Norton Phone: +1-703-299-1656
> DTI Associates, Inc. Fax: +1-703-706-0476
> 2920 South Glebe Road Internet: email@hidden
> Arlington, VA 22206-2768 or email@hidden
> _______________________________________________
> applescript-users mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/applescript-users


  • Prev by Date: Re: How to examine folder contents
  • Next by Date: Re: [OFF] running out of steam...run out and scream!
  • Previous by thread: Re: More about Records
  • Next by thread: Re: More about Records
  • Index(es):
    • Date
    • Thread