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: hd <email@hidden>
- Date: Thu, 1 Apr 2010 02:46:35 +0100
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