Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OSAX to Tokenize Record Field Names from List Items ???



On Jun 22, 2007, at 7:20 PM, Rick Gordon wrote:

How might one go about the process of parsing a list, for instance:

{"fSource", "PicName", "fObjStyle", "[Basic Graphics Frame]", "fWidth", "12p6", "fHeight", "9p3"}

... and dynamically build a record, such as:

{fSource:"PicName", fObjStyle:"[Basic Graphics Frame]", fWidth:"12p6", fHeight:"9p3"}

... without having those field names predefined.

For starters, this works ...
on run
set aList to {"recName", 5}
set scriptText to "{" & (item 1 of aList) & ":" & (item 2 of aList) & "}"
set aRec to do script scriptText
display dialog (recName of aRec)
end run


But, it might be better to use two synchronized lists, 'nameList' containing the record item names, and 'valuelist' containing the associated values, then proceed like this ...

on recordFromLists(nameList, valuelist)
	recLen to (count items of nameList)
	if recLen ≠ (count items of valuelist) then error "unequal lists"
	repeat with i from 1 to recLen
		
	end repeat
end recordFromLists

The recordFromLists handler will need to report errors ... just in case something's not right.
Or you could be carefulll not te mak misteeks.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >OSAX to Tokenize Record Field Names from List Items ??? (From: Rick Gordon <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.