• 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: Creating a plist file in Applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating a plist file in Applescript


  • Subject: Re: Creating a plist file in Applescript
  • From: Luther Fuller <email@hidden>
  • Date: Tue, 01 Oct 2013 09:45:22 -0500

On Oct 1, 2013, at 8:17 AM, Jim Brandt wrote:

I have a question about initializing a plist file. Specifically, a plist file tahe is an array of arrays (list of lists).

I have read Luther Fuller's "Property List Tutorial". I have built plist files that have a single key that references a list of lists. What I want to do is eliminate the key and make a plist whose record structure is a list of lists with no key.

I haven't looked at my "Property List Tutorial" in awhile. It's currently dated Feb 2011.
And it's still in draft. I will finish it and post it somewhere if anyone can recommend a site.

I did check one of my applications that creates a .plist preference file and found this handler ...

on makeNewPlistFile(folderAlias, filename, initialRecord)
try
return ((folderAlias as text) & filename & ".plist") as alias -- the file already exists
end try
set newFileName to (folderAlias as text) & filename
tell application "System Events"
make new property list item with properties {kind:record, value:initialRecord}
make new property list file with properties {contents:the result, name:newFileName}
set newFileName to (path of the result)
end tell
return (newFileName as alias)
end makeNewPlistFile --------------------------------------------------------------------

This is more or less the same thing Shane Stanley is doing in his response.

The code for changing the content of the .plist file is super simple …
Just write a new AppleScript record to the file. For example …

tell application "System Events" to set value of property list file (prefsFile as text) to prefsRec 

(where 'prefsFile' is an alias to a .plist file.)
In this code 'prefsRec' is any AppleScript record. You don't need xml.
You do need to know how to concatenate records and how AppleScript's
data types differ from .plist data types.



 _______________________________________________
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

References: 
 >Creating a plist file in Applescript (From: Jim Brandt <email@hidden>)

  • Prev by Date: Re: Creating a plist file in Applescript
  • Next by Date: Re: AppleScript-Users Digest, Vol 10, Issue 348
  • Previous by thread: Re: Creating a plist file in Applescript
  • Next by thread: Re: AppleScript-Users Digest, Vol 10, Issue 348
  • Index(es):
    • Date
    • Thread