• 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: Searching for the equivalent of coercing to type "record"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Searching for the equivalent of coercing to type "record"


  • Subject: Re: Searching for the equivalent of coercing to type "record"
  • From: Paul Berkowitz <email@hidden>
  • Date: Fri, 07 Mar 2003 13:02:10 -0800

On 3/7/03 12:26 PM, "Steve Cunningham" <email@hidden> wrote:

>> ----------------------------
>> run script ("{<<class usrf>>:{\"a\", \"b\"}} as record")
>> --> {a:"b"}
>> ----------------------------
>>
>> Emmanuel
>
> Thanks! That's a new one on me. Took me a while to figure out Chevrons
> weren't Greater Than and Less Than signs :-)
>
> Sorry to be so clueless, but how am I supposed to get variables into the
> \"a\" and \"b\" slots from outside of the script? I tried globals, but
> they didn't work.
>
> I can't find out any information on this in the AppleScript Language
> Guide or O'Reilly's. Could you point me to a better source?
>
They're just strings, so use variables which you can set to any strings
(perhaps in a repeat loop?) Of course you have to separate the variables out
from the hard-coded string representing the the script by (" & var & ").
here:

set {theLabel, theValue} to {"x", "y"} -- or any two strings

run script ("{<<class usrf>>:{\"" & theLabel & "\", \"" & theValue & "\"}}
as record")

--> {x:"y"}

set {theLabel, theValue} to {"key", "value"}

run script ("{+class usrf;:{\"" & theLabel & "\", \"" & theValue & "\"}} as
record")

--> --> {|key|:"value"}

If you happen to pick a label which is an AppleScript reserved key word
(like 'key') AS will put it in |pipes| to preserve it as your own user-term
(like a variable).
--
Paul Berkowitz
_______________________________________________
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.

References: 
 >Re: Searching for the equivalent of coercing to type "record" (From: Steve Cunningham <email@hidden>)

  • Prev by Date: Re: Searching for the equivalent of coercing to type "record"
  • Next by Date: Re: Searching for the equivalent of coercing to type "record"
  • Previous by thread: Re: Searching for the equivalent of coercing to type "record"
  • Next by thread: Re: Searching for the equivalent of coercing to type "record"
  • Index(es):
    • Date
    • Thread