Re: error 10
Re: error 10
- Subject: Re: error 10
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 31 Aug 2003 08:47:37 -0700
On 8/31/03 7:16 AM, "Oz Springs" <email@hidden> wrote:
>
>
at this point the script hangs and Safari crashes:
>
>
tell application "Safari" to save document 1 in _file
>
>
I think there is something wrong with the "save" part of this and maybe Safari
>
hasn't implemented this part of AppleScript, even though it is in its
>
dictionary. Script Debugger acknowledges "file" (file=file), but it just
>
hovers over "save" without showing anything.
First of all, in OS X you are supposed to save files in Unicode file paths,
NOT 'as file specification', although both should be coerced to the 'real"
fileURL. So John's first version was better:
tell app "Safari" to tell the front document
set AppleScript's text item delimiters to "/"
set _doc to last text item of (get its URL)
set AppleScript's text item delimiters to ""
set f to (path to desktop as Unicode text) & _doc
save in file f
end
I confirm the error you're seeing in OS 10.2.6. I get that error 10
consistently.
John must be using Panther, where there is no error 10. However, there are
still two corrections that will need to be made, when you get there:
1. The URL might end in a "/", so then the last text item is "" and you'd be
trying to save a file in the desktop's own path. Won't work.
2. For me, files (perhaps only when the _doc includes periods and thus a
"false extension" at the end) doesn't actually show up on the desktop unless
I add a real ".html" extension. I don't know if that's a bug or not:
tell application "Safari" to tell the front document
set AppleScript's text item delimiters to "/"
set theURL to (get its URL)
set _doc to last text item of theURL
if _doc = "" then set _doc to text item -2 of theURL
set AppleScript's text item delimiters to ""
set f to (path to desktop as Unicode text) & _doc & ".html"
save in file f
end tell
That works (not in Jaguar).
But you should probably get rid of those extra periods like this:
tell application "Safari" to tell the front document
set AppleScript's text item delimiters to "/"
set theURL to (get its URL)
set _doc to last text item of theURL
if _doc = "" then set _doc to text item -2 of theURL
set AppleScript's text item delimiters to "."
set _doc to text items of _doc
set AppleScript's text item delimiters to "-"
set _doc to _doc as Unicode text
set AppleScript's text item delimiters to ""
set f to (path to desktop as Unicode text) & _doc & ".html"
save in file f
end tell
That's how it _should_ work, but is broken in Jaguar. I really don't think
(again) that we're meant be discussing Panther here, although I've finally
succumbed.
I think it would be best if anyone offering suggestions for scripting Apple
apps tests in Jaguar before posting here, and not refer to Panther versions.
Although it would be even better if someone from Apple said it was in fact
OK to do so, since there seems to be no other forum where we can.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.