OO3: Workaround for scripting save as bug
mentorsw
omni at mentorsw.com
Sun Nov 28 15:27:37 PST 2004
For those working with scripting the OO3 beta, there is a bug related to
doing the equivalent of a Save As... on a document. [NOTE to OmniGroup:
Bug report to follow] The following script fails:
tell application "OmniOutliner Pro3B3"
activate
-- make a new document
make new document at the end of documents
set newDocument to front document
--make a new row
make new row at end of rows of newDocument
set theRow to last row of newDocument
set text of cell 2 of theRow to "Testing..."
set newFile to choose file name
tell newDocument
try
save in newFile
on error errormessage number errornumber from offendingObject
display dialog errormessage buttons {"OK"} default button 1
end try
end tell
end tell
The workaround:
MakeANewDocument()
activate
set newFile to choose file name
DoSaveAs(newFile)
on DoSaveAs(newFile)
-- get filename
set newFilePOSIXPath to POSIX path of newFile as Unicode text
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"/"}
set newFileName to last text item of newFilePOSIXPath
set AppleScript's text item delimiters to oldDelims
-- Add extension if necessary
if newFileName does not end with ".oo3" then
set newFileName to newFileName & ".oo3"
set newFilePOSIXPath to newFilePOSIXPath & ".oo3"
end if
set newFile to POSIX file newFilePOSIXPath
tell application "OmniOutliner Pro3B3"
activate
set newDocument to front document
try
save newDocument as "OmniOutliner 3" in newFile
on error errormessage number errornumber from offendingObject
display dialog errormessage buttons {"OK"} default button 1
end try
end tell
end DoSaveAs
on MakeANewDocument()
tell application "OmniOutliner Pro3B3"
activate
-- make a new document
make new document at the end of documents
set newDocument to front document
--make a new row
make new row at end of rows of newDocument
set theRow to last row of newDocument
set text of cell 2 of theRow to "Testing..."
end tell
end MakeANewDocument
____________________
David Amis
Mentor Software,Inc.
Atlanta, GA
(404) 228-4640
More information about the OmniOutliner-Users
mailing list