PDA

View Full Version : applescript: text snippets


steve
05-16-2006, 09:55 AM
Could someone help me with an applescript that could add pre-defined set of rows?

I'll give an example: Say that I have an outline for meeting agendas.

I. Meeting with Board
* Roll
* Review Agenda
* Approve Agenda
II. Meeting with Donors
* Roll
* Review Agenda
* Approve Agenda

I would want to be able to invoke this applescript and add the rows (roll, review agenda, etc). I was playing with automator and I am only able to add the rows to the top level.

I know I can make a template, but I want to make it more flexible.

Thanks,
Steve

Tim Wood
05-18-2006, 08:50 PM
Something like the following would work:


tell application "OmniOutliner Professional"
set MyDocument to front document

try
-- If there is a selection, add our new rows underneath it
set MyParent to last selected row of MyDocument
on error
-- 'last selected row' will raise an error if there are zero selected rows; add the new rows at the top level in this case
set MyParent to MyDocument
end try

tell MyParent
tell (make new child with properties {topic:"I. Meeting with Board"})
make new child with properties {topic:"* Roll"}
make new child with properties {topic:"* Review Agenda"}
make new child with properties {topic:"* Approve Agenda"}
set expanded to true
end tell
tell (make new child with properties {topic:"II. Meeting with Donors"})
make new child with properties {topic:"* Roll"}
make new child with properties {topic:"* Review Agenda"}
make new child with properties {topic:"* Approve Agenda"}
set expanded to true
end tell
end tell

end tell

Lizard
05-19-2006, 10:10 AM
If you're using Outliner Standard, remove 'Professional' from the first line.
And if you just want the three rows to be added after your selection, trim it down to:

tell application "OmniOutliner Professional"
set MyDocument to front document

try
-- If there is a selection, add our new rows underneath it
set MyParent to last selected row of MyDocument
on error
-- 'last selected row' will raise an error if there are zero selected rows; add the new rows at the top level in this case
set MyParent to MyDocument
end try

tell MyParent
make new child with properties {topic:"Roll"}
make new child with properties {topic:"Review Agenda"}
make new child with properties {topic:"Approve Agenda"}
set expanded to true
end tell


end tell