• 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: does property exists in a record
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: does property exists in a record


  • Subject: Re: does property exists in a record
  • From: "Neal A. Crocker" <email@hidden>
  • Date: Sun, 12 Aug 2001 00:22:22 -0700

play with the script I've included at the end of this message. you ought to be able modify it to produce a script that generates references to record fields from strings containing field names. Such references can be created even for fields that don't exist. Trying to get the contents of a non-existant record field using a reference to it will, of course, generate an error. You can use a try block, much as you've done in the "propertyExists" handler in you original post, to catch that error and do whatever is necessary for a non-existant record field.

When playing with the script I've included, be sure to read the comments in the script. It's tricky to compile. Also, the << and >> characters represent chevrons.


Neal.

Date: Sat, 11 Aug 2001 00:33:51 +1000
Subject: Re: does property exists in a record
From: Adam Hinshaw <email@hidden>
To: <email@hidden>

on 11/08/01 12:14 AM, Paul Skinner at email@hidden wrote:

> 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

problem is the property names i will be searching for are not constant.
They come from strings and will vary.

is there a way then to coerce a string to a record property ??

doesn't look like it at the moment.

adam.



The script below uses << and >> to represent left and right (or is it right and left) chevrons (Option-\ and Shift-Option-\). Watch for line wrapping.
______SCRIPT_______________

on makereference(propname, target)
script refscript
--{class:reference,<<class form>>:<<constant ****usrp>>, <<class want>>:<<class prop>>, <<class seld>>:propname, <<class from>>:target} -- precompiled version of line below
{class:reference, <<class form>>:<<constant ****usrp>>, <<class want>>:property, <<class seld>>:propname,
  • Follow-Ups:
    • Re: does property exists in a record
      • From: Bryan <email@hidden>
    • Re: does property exists in a record
      • From: Bryan <email@hidden>
  • Prev by Date: Re: apply catalog info
  • Next by Date: QT, present command
  • Previous by thread: Re: does property exists in a record
  • Next by thread: Re: does property exists in a record
  • Index(es):
    • Date
    • Thread