Re: Property lists and System Events (was: no subject)
Re: Property lists and System Events (was: no subject)
- Subject: Re: Property lists and System Events (was: no subject)
- From: "Mark J. Reed" <email@hidden>
- Date: Wed, 31 Mar 2010 21:52:16 -0400
Sure, but that's not creating a System Events property list file
object; that's manually assembling the bits that let System Events
expects to see, violating encapsulation. So despite being pure AS,
that's an inferior solution to the one using "defaults write".
On Wednesday, March 31, 2010, hd <email@hidden> wrote:
> On 1 Apr 2010, at 01:46, Shane Stanley wrote:
>
>> On 1/4/10 11:42 AM, "Luther Fuller" <email@hidden> wrote:
>>
>>> I still suspect that System Events does not know a property list file from a
>>> trash icon.
>>
>> It knows them and can read and modify them; it just can't seem to create
>> them.
>
>
> If I start with the example I quoted from Ben Waldie and write the xml header to a text file first:
>
> set theEmptyPListData to "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
> <!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
> <plist version=\"1.0\">
> <dict/>
> </plist>"
>
> set theOutputFolder to path to desktop folder as string
> set thePListPath to theOutputFolder & "myPListFile.plist"
> set thePListFile to open for access thePListPath with write permission
> set eof of thePListFile to 0
> write theEmptyPListData to thePListFile starting at eof
> close access thePListFile
>
> --then I can write properties to the new .plist file:
>
>
> set p_path to POSIX path of thePListPath
> tell application "System Events"
> set the_props to property list file p_path
> tell the_props
> tell contents
> make new property list item at end of property list items with properties {name:"Property1", value:"First property"}
> make new property list item at end of property list items with properties {name:"Property2", value:"Another Property"}
> make new property list item at end of property list items with properties {name:"Property3", value:yes}
> make new property list item at end of property list items with properties {name:"Property4", value:current date}
>
> end tell
> end tell
> end tell
>
>
> HTH
>
>
>>
>>
>> --
>> Shane Stanley <email@hidden>
>> AppleScript Pro, April 2010, Florida <http://www.applescriptpro.com>
>>
>>
>> _______________________________________________
>> 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
>
> _______________________________________________
> 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
>
--
Mark J. Reed <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:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden