Re: Searching for the equivalent of coercing to type "record"
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 09:03:04 -0800
On 3/7/03 8:11 AM, "Emmanuel" <email@hidden> wrote:
>
At 8:07 AM -0500 07/03/03, Steve Cunningham wrote:
>
> I have a tab-seperated text file of the form:
>
>
>
> "field_name_x" (tab) "field value" (tab) "field_name_y" (tab) "field
>
> value" (return)
>
> "field_name_x" (tab) "field value" (tab) "field_name_y" (tab) "field
>
> value" (return)
>
> ... etc
>
>
>
> I know the set of possible field names, but not which will appear in any
>
> given record or in what sequence
>
>
>
> What I'd like to end up with is an AppleScript record of the form:
>
>
>
> {field_name_x: "field value",field_name_y: "field value"}
>
>
I think that you will be interested in the following snippet:
>
>
do script ("{<<class usrf>>:{\"a\", \"b\"}} as record")
>
--> {a:"b"}
>
>
(put chevrons where suitable)
And it also works with 'run script', a Standard Addition command.
Smile and Script Debugger both have 'do script' in the Miscellaneous Suites
of their respective dictionaries. But it won't work outside those editors
when not in a tell block, nor for users without one of those apps. It won't
compile in Script Editor.
I'm sure there's a good reason for including 'do script' in the better
editors' dictionaries, but 'run script' is the one to use for general
purposes. <<class usrf>> (substitute chevrons) is a great device.
--
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.