• 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: How do you check the equivalency of references?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do you check the equivalency of references?


  • Subject: Re: How do you check the equivalency of references?
  • From: Nigel Garvey <email@hidden>
  • Date: Fri, 10 Aug 2001 14:29:38 +0100

At the beginning of this thread, Anthony described the difficulties in
determining whether or not the value of a variable was a reference or the
real thing. This handler may help, though it probably needs to be adapted
to cope with the long-string problem that's been mentioned (and possibly
with other problems that haven't occurred to me).

on isRef(val)
try
contents of val
return (result is not val)
on error
return false
end try
end isRef

Thus:

script anScript_Obj
property nada : ""
end script
set anObj_ref_A to a reference to anScript_Obj

{isRef(anScript_Obj), isRef(anObj_ref_A)}
--> {false, true}

One way to see if two variables ultimately refer to the same original
value (not necessarily the same original object) is to see if they
'contain' each other:

anScript_Obj contains anObj_ref_A and anObj_ref_A contains anScript_Ob
--> true

A faster way would be to coerce both variables to items and compare the
results directly, but this errors with variables that are references to
references.

This only partially addresses Anthony's problem, but it's offered for
what it's worth.

NG


  • Prev by Date: Getting list of open files in Excell
  • Next by Date: does property exists in a record
  • Previous by thread: Re: How do you check the equivalency of references?
  • Next by thread: Re: How do you check the equivalency of references?
  • Index(es):
    • Date
    • Thread