• 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: string as key to record
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string as key to record


  • Subject: Re: string as key to record
  • From: Malcolm Fitzgerald <email@hidden>
  • Date: Fri, 20 Sep 2002 11:43:18 +1000

At 11:43 PM +0100 16/9/02, John Delacour wrote:
At 2:05 pm -0700 16/9/02, john mead wrote:

Is it possible to use a string as a key to a record?
Is there a coercion that would work here?

set myRecord to {thingOne:"blah"}
set myKey to "thingOne"
get myKey of myRecord


set varKey to "a"
set varVal to "3"
set varRecord to run script "
{" & varKey & ":" & varVal & "}"
return a of varRecord

-- JD


John's script does not work if varVal is a string. The script sees an unquoted string value, expects that to be a variable and complains that the variable is undefined. Including the quotes in the concatenation fixes it.

set varKey to "a"
set varVal to "3"
set varRecord to run script "
{" & varKey & ":" & "\"" & varVal & "\"" & "}"
return a of varRecord


--
--
Malcolm Fitzgerald email@hidden
Database Manager http://www.asauthors.org
The Australian Society of Authors ph: 02 93180877 fax: 02 93180530
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: string as key to record
      • From: Paul Berkowitz <email@hidden>
References: 
 >string as key to record (From: john mead <email@hidden>)
 >Re: string as key to record (From: John Delacour <email@hidden>)

  • Prev by Date: Re: HOW TO TURN ON COMPUTER?
  • Next by Date: New version of SpamCopSend script for OSX 10.2 Mail...
  • Previous by thread: Re: string as key to record
  • Next by thread: Re: string as key to record
  • Index(es):
    • Date
    • Thread