Re: Best way to get at these text elements
Re: Best way to get at these text elements
- Subject: Re: Best way to get at these text elements
- From: kai <email@hidden>
- Date: Wed, 4 Oct 2006 02:07:37 +0100
On 1 Oct 2006, at 14:23, Jaime Magiera wrote:
I'm working on a project that requires parsing a .plist file with
plain vanilla AS. Though I've written a parser for server
configuration files before, my knowledge of AS techniques is
limited. Below is the text to parse...
On 2 Oct 2006, at 17:30, he also wrote:
Yeah, I have a version of the script that uses Property List Suite.
However, I have to write a version that works < 10.4. There are
still holdouts in my production environment.
I'd normally have suggested using System Events' Property List Suite
too, Jaime. However, in view of the above situation, here's an
example routine that should extract the values from the type of data
given:
--------------
to list_values from l
set t to text item delimiters
repeat with d in {"\"", "; "}
set text item delimiters to d
set l to l's text items
set text item delimiters to ""
set l to l as Unicode text
end repeat
set text item delimiters to "{"
set l to rest of l's text items
set text item delimiters to " = "
repeat with r in l
tell r to set contents to rest of text items
repeat with i in r
tell i to set contents to paragraph 1
end repeat
end repeat
set text item delimiters to t
l
end list_values
set plist to "(
{
baseURL = \"http://adomain.com\";
displayName = \"Adomain\";
host = \"www.adomain.com\";
protocol = \".mac\";
remotePath = \"/Sites/podcast\";
serverUniqueID = 1158377199.667244;
username = jmagiera;
},
{
baseURL = \"http://www.adomain2.com\";
displayName = Adomain2;
host = \"idisk.mac.com\";
protocol = \".mac\";
remotePath = \"/Sites/podcast\";
serverUniqueID = 1158373459.790697;
username = jmagiera;
}
)"
list_values from plist
--> {{"http://adomain.com", "Adomain", "www.adomain.com", ".mac", "/
Sites/podcast", "1158377199.667244", "jmagiera"}, {"http://
www.adomain2.com", "Adomain2", "idisk.mac.com", ".mac", "/Sites/
podcast", "1158373459.790697", "jmagiera"}}
--------------
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden