Re: working with records
Re: working with records
- Subject: Re: working with records
- From: Philip Aker <email@hidden>
- Date: Wed, 22 Aug 2007 23:33:00 -0700
On 2007-08-22, at 23:10:07, Wayne Melrose wrote:
On 22/08/2007, at 11:16 PM, Christopher Nebel wrote:
On Aug 21, 2007, at 4:51 AM, Wayne Melrose wrote:
I have a record with different values..
eg
set rec to {username:"wayne",
emailadd:"email@hidden"}
now I can get ..
set username to username of rec
set emailadd to emailadd of rec
that's fine.. but with many items in the record, what I'd like to
do is extract (or expand) all of the items at the same time..
with their label coming the variable name.. is this even possible?
result would be..
set username to "wayne"
set emailadd to "email@hidden"
One wonders what the actual problem you're trying to solve is.
Assuming you can perform this operation, what are you going to do
with all of the variables, whose names, by definition, you do not
know ahead of time?
y'know, I thought it must have looked a little strange.. :) By
definition you would not know ahead of time, in this case I do..
The history is this..
I have a record that is full of records
ie
set mainrec to {{username:"wayne", emailadd:"email@hidden"},
{username:"chris". emailadd:"email@hidden"}, ETC}
I then have to loop through each of those records inside of mainrec
I then expand the record using annoying if statments
set username to username of rec
if username is "wayne" then
set emailadd to emailadd of rec
-- get other variables here
end if
now I have to also deal with empty values.. (values are of course,
not name and email address)
Point being, I'm expanding every record of main rec anyway, and
each time it's the same thing, and it's alot of code.. which seems
pointless if there was an easy way to expand into variables for
each record on each loop.
Does that clear it up or am I starting to sound like a crazy man?
The analogies are available in Carbon CFDictionary and several other
scripting languages standardly installed on Mac OS X. Sometimes it's
very handy to deal with keys, sometimes with values, and sometimes
with both. For instance in Tcl you can get the key(s) of a value and
swap the keys and values.
Philip Aker
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:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden