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

Re: Records


  • Subject: Re: Records
  • From: "Mark J. Reed" <email@hidden>
  • Date: Thu, 3 Nov 2005 13:27:11 -0500

On 11/3/05, Luther Fuller <email@hidden> wrote:
1. A project I started earlier this year (in OS X 10.3) used records constructed
with vertical bar characters, for example: {|a|:somevalue, ...}.
AppleScript will no longer create new labels like this, but the old labels
still work.  Why?

Vertical bars are used to prevent names from being interpreted as dictionary terms; useful if you have a variable whose name is the same as an item in some application's dictionary, for instance. So I guess the point of using them in a record property name is to avoid having a record property be compiled one way where set and a different way where queried later.  Which doesn't explain why the compiler is stripping them.

2. Suppose r is a record only one of whose labels is known.
For example, r = {a:somevalue, ... }.
I need to create a new record that contains everything in r
except property a. (I really, really need this!)
One would think this would be as easy as something like ...
     set n to r
     delete a of n
which, of course, doesn't work. Any ideas?

Well, first, (set n to r) is not what you want in that case.  That just makes n and r both point to the same, single record, so if the delete *did* work it would leave r with no |a| property, either.  You should make n point to a new copy of r, with (copy r to n).

But, unfortunately, there's no way that I know of to delete a property from a record value.  You can add new properties, and you can modify properties in place (so maybe setting n's a to the missing value is good enough for what you're trying to do?), but you can't delete them. 

The only way I know of (but me no expert) to accomplish what you're trying to do requires enumerating all of the properties you *do* want to keep.  Something like this:

set n to {b: r's b, c: r's c, d: r's d,...}

where you just leave a out of the list.

_______________________________________________
Do not post admin requests to the list. They will be ignored. email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: RE: Script Timer/Filemaker question
  • Next by Date: Re: How to work with XML data using System Events?
  • Previous by thread: Re: Records
  • Next by thread: Re: Records
  • Index(es):
    • Date
    • Thread