G’day
I’ve created a plist file that works ok, but I want to check if it exists.
When I use a simple ‘if exists file path-to-name’ I get a -1409 error.
Can anyone advise a fix please?
Regards
Santa
on SetThePlistPath()
set thePListFolderPath to path to preferences folder from user domain as string
set thePListPath to thePListFolderPath & "com.MeSelf.rtfdLoader.plist"
end SetThePlistPath
on EstablishPreferences()
try
my SetThePlistPath()
set theZip to (integer value of button "copyziptodesk" of window 1)
set theSound to (integer value of button "soundon" of window 1)
set expandZip to (integer value of button "expandzip" of window 1)
set emailFlag to (integer value of button "CopyEmail" of window 1)
set theFiledYear to (title of current menu item of popup button "Year Selector" of window 1)
set theFiledPlace to (title of current menu item of popup button "Search" of window 1)
say "this"
tell application "Finder"
if exists file thePListPath then
beep 4
end if
if not (exists file thePListPath) then
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 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
end if
--set thePListPath to POSIX path of (thePListFolderPath & "com.MeSelf.rtfdLoader.plist")
tell application "System Events"
tell property list file thePListPath
tell contents
say "trying"
set value to {|TheZip|:theZip, |TheSound|:theSound, |ExpandZip|:expandZip, |emailFlag|:emailFlag, |TheYear|:theFiledYear, |ThePlace|:theFiledPlace}
say "success"
end tell
end tell
end tell
end tell
on error errmsg number errnum
display dialog errmsg & return & return & errnum
end try
end EstablishPreferences