I have revisited the idea of using OO3 to maintain a list of todo items. When ticked off the items should be moved to a completed section. The difficulty is that I want to preserve the structure so that a complex task may be split into a number of smaller actions and when these are ticked off they and the parent are copied to the closed actions. The code posted below works but it is crude as I suspect that there are better methods of moving an item and its parents. Any advice will be welcomed. To test the code create an Outline where the actions are on the third level and the outline has two sections .
Thanks
Simon
Thanks
Simon
Code:
(* This code is a prototype that is designed to work with an outline of open and closed action items. It assumes that the open items are the first child section of the document and the closed items are listed in the second child of the document. This code attempts to maintain the simple structure in both sections e.g. Open Actions -Home -- Do this -- Next this -Work -- complete report -- play golf Closed Actions -Home -- Feed Cat -- Walk Dog The aim is to extend this code to allow and maintain more complex structures where the only rule is that the actual action is written on the lowest level. At present the code is hard wired to three levels only *) -- set var to refer to this document set original to front document of application "OmniOutliner Professional" tell front document of application "OmniOutliner Professional" -- A brand new document may not have any rows so trap for this condition -- create a blank row if the document has no rows (i.e brand new document) - unlikely if not (exists (last child of original)) then tell original make new row at end of rows end tell end if set OpenActions to first child of original -- e.g Open Actions set ClosedActions to second child of original -- e.g Closed Actions --Loop through the lowest items in the first section i.e. Open Actions repeat with oneRow in (every row of first child of original whose has subtopics of it is false) if (state of oneRow is equal to checked) then -- This row has to be moved. -- Read the data of the row and its parent into variables set myparent to the parent of oneRow set MyAction to value of cell "Action" of oneRow set MyParentAction to value of cell "Action" of myparent set ActionExists to false -- Used as a flag -- Check to see if parent already exists in Closed Actions section --! Unable to discover a repeat until syntax that allows all the rows to be processed repeat with tRow in (every row of ClosedActions whose has subtopics of it is true) set tAction to value of cell "Action" of tRow -- read the value and store in tRow if tAction is equal to MyParentAction then -- compare values set ActionExists to true -- Add the new completed item set CopiedAction to make new child at end of rows of tRow set the value of cell "Action" of CopiedAction to MyAction -- I was unable to get the following single line to work -- set CopiedAction to make new child at end of rows of tRow with properties {Action:MyAction} end if end repeat --looping through each row of Closed actions -- At this point the checked row has been duplicated if the parent exists -- If the parent does not exist then add both the parent and child if ActionExists is false then -- Add the new container topic then add our new completed action --set newRow to make new row at end of rows of newDoc set tNewParent to make new row at end of rows of ClosedActions set the value of cell "Action" of tNewParent to MyParentAction set CopiedAction to make new child at end of rows of tNewParent set the value of cell "Action" of CopiedAction to MyAction end if --! Add code to delete the checked item from the Open Actions end if -- the item was checked or ticked end repeat end tell