The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   AppleScripting Omni Apps (http://forums.omnigroup.com/forumdisplay.php?f=46)
-   -   OO3 Move items script (http://forums.omnigroup.com/showthread.php?t=22291)

Simon Knight 2011-10-05 02:38 PM

OO3 Move items script
 
Hi, I have searched the web for an answer to this question and found nothing so I guess that the answer is obvious....

I wish to move ticked item rows to a different section in my document. I thought that changing the value of the ancestor topic might make the items move but it just changed the parent topic :

[CODE]set the topic of ancestor of oneRow to "Completed Actions"[/CODE]

Any ideas of how to move the row to a new location and also to restrict the script to a section ?

Thanks
Simon

whpalmer4 2011-10-05 03:54 PM

Yeah, as you've discovered, you're just renaming the parent with that construct, not assigning the child a new parent.

Have a look at the Move Completed Items script in the collection of Useful Scripts on the OmniOutliners Extras page: [url]http://www.omnigroup.com/products/omnioutliner/extras/[/url]

One obvious way to restrict the scope of action would be to make it only work on the selected rows at the time of invocation.

Simon Knight 2011-10-05 11:22 PM

I have had a look at the example script and have quoted part of it below along with my thoughts on what the code is doing. I would like to know if I am correct:
[CODE]-- create the entry for today in the done document if it isn't already there
if not (exists (last child of doneDoc)) then
tell doneDoc
make new row at end of rows
end tell
end if
[/CODE]
I think he children of a OO3 document are its top level rows, a new document has no rows so has no "last child". If I'm correct then this block is saying "add a new top level row to the new document"

[CODE]
set newRow to last child of doneDoc
if dateString is not equal to (topic of newRow) then
set newRow to make new row at end of rows of doneDoc
set topic of newRow to dateString
end if
[/CODE]
This section compares the text value (topic) of the final section with todays date. If they are different a new row is added. The line "set newRow to make new row at end of rows of doneDoc" seems to be doing two actions the first is to add a new row to the document the second is to set that row to the variable newRow which allows the subsequent line to set the value to todays date.

[CODE]
-- copy the checked items
duplicate (every row of original whose state is checked and has subtopics of it is false) to end of children of newRow
[/CODE]
newRow was created above and this code duplicates every checked row in the list document and pastes them into done.oo3 as children of newrow
[CODE]
delete (every row of original whose state is checked and has subtopics of it is false)
set expanded of newRow to true[/CODE]

Looking at this code am I correct in thinking that OO3 does not associate rows with other rows other than by their position and level in the list. My code in the original post failed to work in the way I expected because the section headers are not containers in any way and have no knowledge of the rows under them in the document? In order to move a row to a new position in the document I need to write code that locates where the target section is and set a variable to that section. Code can then add new rows as children this row as described above.

Am I alone in finding Applescript both powerful and obscure? The ability to duplicate every selected row in a single command is powerful but I would have never found the command or understood it from reading its dictionary entry.

Thanks for the steer to the example script.

best wishes
Simon

Simon Knight 2011-10-18 07:41 AM

Just in case anyone is interested I posted details of my latest ToDo list in the general OO forum pages.


[URL="http://forums.omnigroup.com/showthread.php?t=22357"]http://forums.omnigroup.com/showthread.php?t=22357[/URL]


All times are GMT -8. The time now is 03:49 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.