• 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: shell script - duplex printing prefs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shell script - duplex printing prefs


  • Subject: Re: shell script - duplex printing prefs
  • From: Axel Luttgens <email@hidden>
  • Date: Sun, 01 Apr 2007 00:02:18 +0200

On 31/03/07 21:12, Luther Fuller wrote:

On Mar 31, 2007, at 1:39 PM, Axel Luttgens wrote:

Assuming a preset "Test" already exists, you could do something like this:

[...]


This may work with your file "com.apple.print.custompresets.plist", but it will NOT work on mine. A command such as ...

tell application "System Events"
    set value of property list item "x" of property list file "y"
end tell

will work without error only if property list item "x" already exists in property list file "y". If it does not exist, then "System Events" will error without warning (in other words, your script mysteriously dies). My copy of "com.apple.print.custompresets.plist" contains only the value "com.apple.print.lastPresetPref" = "Standard" and will therefore crash this script.

This is why


... I wrote: 'Assuming a preset "Test" already exists'. ;-)

you need to read the value of the entire plist file into a record; then concatenate new items to the record; then set new values; then write the entire record back to the plist file.


I thought this would have been obvious but yes, as soon as one wants to change the structure of a property list item (the root dictionary, ie the whole plist, being just a special case), that whole property list item needs to be rewritten by setting its value to the wanted record.
Thanks for having made that point explicit.


Knowing the rules for concatenating records properly is a necessity.


Axel
_______________________________________________
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: 
 >shell script - duplex printing prefs (From: Nick Hearn <email@hidden>)
 >Re: shell script - duplex printing prefs (From: Axel Luttgens <email@hidden>)
 >Re: shell script - duplex printing prefs (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: shell script - duplex printing prefs
  • Next by Date: Re: Return PDF default reader
  • Previous by thread: Re: shell script - duplex printing prefs
  • Next by thread: How does one save a vcard?
  • Index(es):
    • Date
    • Thread