• 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: interesting discovery (trying to get record labels as strings)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: interesting discovery (trying to get record labels as strings)


  • Subject: Re: interesting discovery (trying to get record labels as strings)
  • From: "Neal A. Crocker" <email@hidden>
  • Date: Mon, 3 Dec 2001 19:44:06 -0800

Date: Mon, 3 Dec 2001 17:28:09 -0500
From: Victor Yee <email@hidden>
Subject: Re: interesting discovery (trying to get record labels as
strings)
To: applescript-users <email@hidden>

On Mon, 03 Dec 2001 14:03:01 -0800, Paul Berkowitz wrote,

> Is there a way to coerce the string "hello" into a call to the record? (i.e.
> hello of {hello:"goodbye"})

set myRec to {{+class usrf;:{"hello", "goodbye"}}} as string as record
hello of myRec
-- "goodbye"

Sorry, maybe I was a little vague. What I was looking for something like:

set a to "hello"
set b to "goodbye"
set myRec to {{+class usrf;:{a, b}}} as string as record
get a of myRec -- somehow coerce a variable string into a call to the record

Is it possible?

The problem with records (as others have pointed out) is that calling the keys
has to be hardwired into the code. The AppleScript team is apparently working on
it, but that probably wouldn't be available for anything less than MacOS X.


try this script (watch out for line wraps and conversion of chevrons to wierd characters like + and ;):

--begin script
on makereference(propname, target)

set refobj to refrec of ({{refrec:{class:reference,+class form;:+constant ****usrp;, +class want;:+class prop;, +class seld;:propname, +class from;:target}}} as string as record)
return refobj

-- the line above will change upon compilation and won't compile a second time.
-- The commented line below holds a copy which can be used for future compilations.
-- set refobj to refrec of ({{refrec:{class:reference,+class form;:+constant ****usrp;, +class want;:+class prop;, +class seld;:propname, +class from;:target}}} as string as record)
end makereference

set blah to makereference("hello", {hello:"goodbye"})
contents of blah -- returns "goodbye"
--end script


Victor

p.s. Chris N. (if you're reading this), how about a quick and AS native way to
get the index of an item in a list. That would make handling associated lists so
much nicer :)


  • Prev by Date: <<event FNDRsope>> (WAS Re: Path to app ...)
  • Next by Date: Alert on new FileMaker Record creation
  • Previous by thread: Re: interesting discovery (trying to get record labels as strings)
  • Next by thread: Re: interesting discovery (trying to get record labels as strings)
  • Index(es):
    • Date
    • Thread