Re: OSAX to Tokenize Record Field Names from List Items ???
Re: OSAX to Tokenize Record Field Names from List Items ???
- Subject: Re: OSAX to Tokenize Record Field Names from List Items ???
- From: Luther Fuller <email@hidden>
- Date: Sat, 23 Jun 2007 15:01:52 -0500
Another suggestion ...
The original question asks how to convert a list to a record. A
better solution might be not to waste time and effort constructing
the list, but to construct the record directly, item by item. The
original list was ...
{"fSource", "PicName", "fObjStyle", "[Basic Graphics Frame]",
"fWidth", "12p6", "fHeight", "9p3"}
Build the record like this ...
set aRecord to (run script ("{" & "fSource" & ":" & "PicName" & "}"))
set aRecord to aRecord & (run script ("{" & "fObjStyle" & ":" &
"[Basic Graphics Frame]" & "}"))
set aRecord to aRecord & (run script ("{" & "fWidth" & ":" & "12p6" &
"}"))
set aRecord to aRecord & (run script ("{" & "fHeight" & ":" & "9p3" &
"}"))
You are probably building the list within a loop, so all you need is ...
repeat something in somethingelse
-- get next record item name = itemName
-- get next record item value = itemValue
set aRecord to aRecord & (run script ("{" & itemName & ":" &
itemValue & "}"))
end repeat
On Jun 23, 2007, at 1:58 PM, Michelle Steiner wrote:
On Jun 23, 2007, at 11:00 AM, Luther Fuller wrote:
on run
set aList to {"recName", 5}
set scriptText to "{" & (item 1 of aList) & ":" & (item 2 of
aList) & "}"
set aRec to run script scriptText
display dialog (recName of aRec)
end run
And here is a generic solution:
on run
set scriptText to "{"
set aList to {"recName", 5, "rec2", 2, "rec3", "\"third record\"",
"rec4", true, "rec5", false}
repeat with i from 1 to (count aList) by 2
set scriptText to scriptText & (item i of aList) & ":" & (item (i
+ 1) of aList) & ","
end repeat
set scriptText to text 1 through -2 of scriptText
set scriptText to scriptText & "}"
set aRec to run script scriptText
end run
-- Michelle
--
"The past is like a foreign country. They do things differently
there." --Leslie Poles Hartley
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden