• 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: Best way to get at these text elements
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to get at these text elements


  • Subject: Re: Best way to get at these text elements
  • From: Philip Aker <email@hidden>
  • Date: Sun, 01 Oct 2006 21:23:25 -0700

On 2006-10-01, at 06:23:57, 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...

[...]

The quoted array () could have any number of elements, which are also arrays, {}.

The {} delimiters enclose a plist dictionary.


I was thinking of doing this line by line, but it would be easier to break it up with text item delimiters. On the other hand, sending it to the command line via do shell script and running it through something else might work. 

Anyone have suggestions for how to approach this? Thanks.

Looks like you're getting the text value from 'defaults read ...'  because that's exactly what a plist array containing dictionaries looks like. So you'd be better off to read the plist directly with 
the items in the Property List suite in System Events. Say the name of the array in the plist is "ServerAccounts". Then:

set f to ((path to desktop as string) & "test.plist")
set res to {}
tell application "System Events"
set plfile to property list file f
set plitem to value of property list item "ServerAccounts" of plfile
repeat with i in plitem
set end of res to i as list
end repeat
end tell
res

would give a result of something like:

{{"Adomain", "jmagiera", ".mac", "http://adomain.com", "www.adomain.com", "/Sites/podcast", "1158377199.667244"}, {"Adomain2", "jmagiera", ".mac", "http://www.adomain2.com", "idisk.mac.com", "/Sites/podcast", "1158373459.790697"}}

Leave off the repeat loop to see what "value of property list item ..." gives if you need access to the keys.


Philip Aker
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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Best way to get at these text elements
      • From: Jaime Magiera <email@hidden>
References: 
 >Best way to get at these text elements (From: Jaime Magiera <email@hidden>)

  • Prev by Date: Applying Character style in Word 2004
  • Next by Date: Re: Applying Character style in Word 2004
  • Previous by thread: Best way to get at these text elements
  • Next by thread: Re: Best way to get at these text elements
  • Index(es):
    • Date
    • Thread