adding rows in scripts
Curtis Clifton
curt.clifton at mac.com
Sat Jan 15 17:48:16 PST 2005
Tim,
On Jan 15, 2005, at 5:35 PM, Timothy J.Wood wrote:
> One suggestion; instead of deleting the original selected row,
> replace it's topic with the first paragraph and then only create new
> rows for paragraphs 2..N. The advantage to this is that if the
> original row had values in non-topic columns, they won't get lost.
Good suggestion. That simplifies the script and makes it safer. The
new version follows my sig.
> Another arguable position would be to copy the non-topic cells to
> the newly created rows... which is correct is largely a matter of
> taste and the operation in question (might even differ on a column by
> column basis! :)
I'll leave that option out unless someone asks for it. :-)
Curt
----------------------------------
Curtis Clifton, PhD Candidate
Dept. of Computer Science, Iowa State University
http://www.cs.iastate.edu/~cclifton
P.S. ("post script", heh)
-- Splits selected row into multiple rows, one for each paragraph
-- Leaves all other data for the selected row attached to the first row
of the result
tell front document of application "OmniOutliner Professional"
try
set v_selrow to selected row 1
on error
beep
display dialog "You must select a row to split." buttons {"Close"}
default button "Close"
return
end try
set v_parent to parent of v_selrow
set v_topic to topic of v_selrow
set theParagraphs to every paragraph in v_topic
-- Nothing to do? Then do it.
if (count of theParagraphs) is 1 then return
-- Creates the new rows
set theOffset to (index of v_selrow)
repeat with v_p in theParagraphs
if (theOffset is (index of v_selrow)) then
set the topic of v_selrow to v_p
else
make new row with properties {topic:v_p} at ¬
after child theOffset of v_parent
end if
set theOffset to theOffset + 1
end repeat
-- Stores some info before deleting the old row
set theOffset to (index of v_selrow)
set theCount to (count of theParagraphs)
select children theOffset thru (theOffset + theCount - 1) of v_parent
end tell
More information about the OmniOutliner-Users
mailing list