Hi,
I have a script which is meant to take the front document of SubEthaEdit and open it in Safari.
However I am having problems getting Safari to admit that the file actually exists!
here is my script:
Code:
tell application "SubEthaEdit"
if (number of windows) < 1 then
display dialog "There are no open subEthaEdit windows." buttons {"OK"} giving up after 1 -- seconds
return
else
set frontDoc to text document of front window
if modified of frontDoc is true then
set saveReply to display dialog "There are Unsaved Changes! Do you want to Save the source?" buttons {"Cancel", "Save"} default button 2
if button returned of saveReply is "No" then
return
else
save frontDoc
end if
end if
try
set theSourcePath to path of frontDoc
-- set theFileAlias to frontDoc as alias
-- log theSourcePath
-- set theFilePath to (POSIX path of frontDoc)
on error errorString number errorNumber
display dialog "This Document has never been saved to a file- It cannot be used."
return
end try
end if
end tell
tell application "Safari"
--make new document at the beginning of documents
--set the URL of the front document to "file:/" & theSourcePath
open (theSourcePath as alias)
end tell
when I try to run it Script Editor and Safari Claim the file does not exist:
Code:
tell application "SubEthaEdit"
count every window of current application
3
get text document of window 1
document "Test.xhtml"
get modified of text document "Test.xhtml"
false
get path of text document "Test.xhtml"
"/Users/diggory/Desktop/Test.xhtml"
"File /Users/diggory/Desktop/Test.xhtml wasn't found."
does anyone know the right way to get Safari to open a local document?