Re: does property exists in a record
Re: does property exists in a record
- Subject: Re: does property exists in a record
- From: Paul Skinner <email@hidden>
- Date: Fri, 10 Aug 2001 10:14:34 -0400
on 8/10/01 9:40 AM, Adam Hinshaw wrote:
>
Hi,
>
im currently stumped with records.
>
>
i want to be able to test that a property exists first before trying to set
>
it.
>
>
If its does not exists i will concatenate it to the record otherwise i want
>
to add stuff to its value (another record)
>
>
my current attempt as test (that is failing)
>
-------------
>
set x to {hello:"world", goodbye:"cruel world"}
>
>
propertyExists(x, "hello" as data)
>
>
on propertyExists(inRecord, theProp)
>
--does a property:theProp exist in a record:theRecord
>
set val to true
>
try
>
set test to theProp of inRecord
>
on error
>
set val to false
>
end try
>
return (val)
>
end propertyExists
>
------------
>
>
can any one see a way, (with out non standard osax ??)
I would just look for it. If it's not there then add it.
--begin script
set x to {hello:"world", goodbye:"cruel world"}
try
hello of x
on error
set x to x & {hello:"world"}
end try
--end script
--
"AppleScript is digital duct tape."
Paul Skinner