• 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: (no subject)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (no subject)


  • Subject: Re: (no subject)
  • From: Luther Fuller <email@hidden>
  • Date: Wed, 31 Mar 2010 09:42:59 -0500

On Mar 31, 2010, at 8:55 AM, Oakley Masten wrote:

Yes Luther I would like to see the examples.

Here's how I create a new preference file:

property defaultPrefsRec : {a:1, b:"string", c:{3, 4, 5}} -- for example
property prefsName : "prefsFileName" -- lookup info on CFBundleIdentifier to find out how to name your prefs file

set prefsFolder to (path to preferences folder from user domain)
set posixPath to quoted form of (POSIX path of prefsFolder)
do shell script "defaults write " & posixPath & prefsName & " x y" -- creates the new property list file with dummy value
tell application "Finder" to set prefsFile to (file (prefsName & ".plist") of prefsFolder) as alias
tell application "System Events" to set value of property list file (prefsFile as text) to defaultPrefsRecord


Reading the preference file:
tell application "System Events" to set prefsRec to (value of property list file (prefsFile as text)) --<<<<<<<<<<<<< READ

You can now modify the record prefsRec as desired.

Writing the preference file:
tell application "System Events" to set value of property list file (prefsFile as text) to prefsRec --<<<<<<< WRITE

Keep in mind that when you look at your preference file with Property List Editor, Array = list and Dictionary = record.

 _______________________________________________
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

  • Follow-Ups:
    • Re: Read Write pList Files
      • From: Oakley Masten <email@hidden>
    • Re: (no subject)
      • From: "Mark J. Reed" <email@hidden>
References: 
 >(no subject) (From: Oakley Masten <email@hidden>)

  • Prev by Date: (no subject)
  • Next by Date: Re: (no subject)
  • Previous by thread: (no subject)
  • Next by thread: Re: (no subject)
  • Index(es):
    • Date
    • Thread