• 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
Record quirk - or bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Record quirk - or bug?


  • Subject: Record quirk - or bug?
  • From: Paul Berkowitz <email@hidden>
  • Date: Wed, 30 May 2001 19:26:31 -0700

Can anyone explain this?

set rec to {a:1, b:2, c:3}
-- {a:1, b:2, c:3}

length of rec
-- 3

count rec
-- 3

contents of rec
-- {a:1, b:2, c:3}

length of (contents of rec)
-- 3

count (contents of rec)
-- 0

0 ?

class of (contents of rec)
-- record


Is this another record that thinks it's a list?

ASLG, p. 75-6, properties of records:

Length An integer containing the number of properties in the record.
This property is read-only.

<snip>

COMMANDS HANDLED
You can count the properties in a record with the Count command. For
example, the value of the following statement is 2.
count {name:"Robin", mileage:4000}
--result: 2


Another way to count the properties in a record is with a Length property
reference. For example, the value of the following reference is 3.
length of {name:"Robin", mileage:8000, city:"Sunnyvale"}
--result: 3

p. 77, Reference

PROPERTIES
--
Contents The value of the object to which the reference refers. The class of
the value depends on the reference. For information about how
to use the Contents property, see 3The A Reference To Operator2

---------

Maybe I shouldn't be using "contents of" anything without first setting a
reference, but it actually came about accidentally, when a particular record
label of a record I was using was "contents" - namely, a keyword in Dialog
Director for its list of items in the Dialog record it uses: I can't change
the label from "contents" to something else. It's a given of Dialog
Director. I always need to get 'contents of aDialog', and sometimes need to
count its items. It works OK if I first set a variable to 'contents of
aDialog' and then count that. Or it works OK always if I use '

length of (contents of aDialog)

(That never gives the length of the main record aDialog, which would be 4.
It always gives the length of the list called "contents", which is usually
about 28 or more.) But

count (contents of aDialog)

is always 0, even though constructions such as

repeat with i from 1 to (count (contents of aDialog))

work just fine. It took a long time until I realized what was going on.

set ls to (contents of aDialog)
count ls

works fine.

Very strange.


--
Paul Berkowitz


  • Prev by Date: Mac OS X Alert Sound
  • Next by Date: Record quirk - or bug?
  • Previous by thread: RE: Mac OS X Alert Sound
  • Next by thread: Record quirk - or bug?
  • Index(es):
    • Date
    • Thread