The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniOutliner 3 for Mac (http://forums.omnigroup.com/forumdisplay.php?f=9)
-   -   Tasks: Days Past Due (http://forums.omnigroup.com/showthread.php?t=14863)

New Horizon 2009-12-29 08:32 AM

Tasks: Days Past Due
 
Is there a way to create a column that will show how many days a task has missed its due date?

Thanks in advanced.

whpalmer4 2009-12-29 10:28 AM

1 Attachment(s)
Yeah, you can write an Applescript that will fill in the column on command (it will [b]not[/b] update dynamically, and you don't want to be editing one of the cells when you run the script). Put the script in the OmniOutliner scripts folder and the Customize Toolbar command will allow you to put a button for it in your toolbar. I don't recall if the ability to make a document-specific toolbar is a OO Pro feature, but if it isn't, that would be even better.

Here's a sample:
[code]
tell application "OmniOutliner"
tell front document
set currentDate to (current date)

if title of every column does not contain {"Date due"} then
display dialog "You need columns named 'Date due' and 'Days overdue' for this script" buttons "Cancel" default button 1
end if
if title of every column does not contain {"Days overdue"} then
display dialog "You need columns named 'Date due' and 'Days overdue' for this script" buttons "Cancel" default button 1
end if

repeat with myRow in every row
if (state of myRow is unchecked) then
set rowDueDate to value of cell "Date due" of myRow
if (rowDueDate is not missing value) then
if (currentDate > rowDueDate) then
set daysOverdue to (currentDate - rowDueDate) / days
else
set daysOverdue to missing value
end if
set value of cell "Days overdue" of myRow to daysOverdue
end if
end if

end repeat
end tell
end tell
[/code]

"Date due" should be a column of type Date, and "Days overdue" should be a column of type Number, and both allow some variation in formatting which you should adjust to suit.

New Horizon 2009-12-29 03:03 PM

Whpalmer4,

Thank you. This is exactly what I'm looking for; however, one problem: I'm new with MACs and weak with Applescript (but strong with Fortran, PERL, and C++), so I'm very willing to learn.

I do not have an "OmniOutliner Scripts" folder in "Applications." The OmniOutliner program is the only thing in Applications.

I am using OO Pro -- had it now for about a week.

I know you explained things below, but I may need some extra hand-holding here because I'm afraid I may waste time trying this and trying that. I've looked at a primer in the OF forum, but nothing that says here's a way that will work if directions are followed exactly.

As I understand, I can create an "OmniOutliner Scripts" folder in the Applications folder. There I put the script you have written and call it anything I want. From there OmniOutliner will know it's there? How to invoke it so the Customize Toolbar knows it is there?

I feel once I get past this point, I'll be able to take off.

Thanks ...


[QUOTE=whpalmer4;71091]Yeah, you can write an Applescript that will fill in the column on command (it will [b]not[/b] update dynamically, and you don't want to be editing one of the cells when you run the script). Put the script in the OmniOutliner scripts folder and the Customize Toolbar command will allow you to put a button for it in your toolbar. I don't recall if the ability to make a document-specific toolbar is a OO Pro feature, but if it isn't, that would be even better.

Here's a sample:
[code]
tell application "OmniOutliner"
tell front document
set currentDate to (current date)

if title of every column does not contain {"Date due"} then
display dialog "You need columns named 'Date due' and 'Days overdue' for this script" buttons "Cancel" default button 1
end if
if title of every column does not contain {"Days overdue"} then
display dialog "You need columns named 'Date due' and 'Days overdue' for this script" buttons "Cancel" default button 1
end if

repeat with myRow in every row
if (state of myRow is unchecked) then
set rowDueDate to value of cell "Date due" of myRow
if (rowDueDate is not missing value) then
if (currentDate > rowDueDate) then
set daysOverdue to (currentDate - rowDueDate) / days
else
set daysOverdue to missing value
end if
set value of cell "Days overdue" of myRow to daysOverdue
end if
end if

end repeat
end tell
end tell
[/code]

"Date due" should be a column of type Date, and "Days overdue" should be a column of type Number, and both allow some variation in formatting which you should adjust to suit.[/QUOTE]

whpalmer4 2009-12-29 03:41 PM

[QUOTE=New Horizon;71098]

Thank you. This is exactly what I'm looking for; however, one problem: I'm new with MACs and weak with Applescript (but strong with Fortran, PERL, and C++), so I'm very willing to learn.
[/quote]

We won't be making any use of the FORTRAN, you can answer any questions I have in the future about the other two and we'll call it even :-)

A personal pet peeve of mine, totally irrational, no argument -- please call it a Mac, not a MAC.

[quote]

I do not have an "OmniOutliner Scripts" folder in "Applications." The OmniOutliner program is the only thing in Applications.

[/quote]
Okay, the tutorial written by RobTrew over in the OF forum will do the right thing if you simply read "OmniOutliner Pro" wherever it says "OmniFocus". However, I'm stuck waiting here, so I'll spell it out for you.

In the top-level Applications folder, there should be a folder called AppleScript, and in it there is the AppleScript Utility application. Launch that, and make sure the "Show Script Menu in menu bar" box is checked. Now launch OmniOutliner Pro, and while OmniOutliner Pro is the foremost application (it should say OmniOutliner Pro in the menu bar at the left), select that AppleScript menu (it will look like a fancy S or perhaps a scroll depending on your imagination) and choose Open Scripts Folder and Open OmniOutliner Pro Folder. This will create the folder in the right place for you, including any other folders needed to create the hierarchy.
[quote]
As I understand, I can create an "OmniOutliner Scripts" folder in the Applications folder. There I put the script you have written and call it anything I want. From there OmniOutliner will know it's there? How to invoke it so the Customize Toolbar knows it is there?
[/quote]

Do as outlined above and you'll have a folder called ~/Library/Scripts/Applications/OmniOutliner Pro where you can deposit scripts intended for use by OmniOutliner Pro, or you can write your own there with the Script Editor (or AppleScript Editor as it is called in Snow Leopard). With the script I provided as text instead of a downloadable script file, you would open up the Script Editor, paste in the text from my post, and save it as "Days past due" (or whatever) in that folder. To add it to your toolbar in OOP, do View->Customize Toolbar... or View->Create Document-specific Toolbar to build a custom toolbar for the current document. Now it's just a matter of dragging icons around to arrange the toolbar you want.

Try it out, give a shout if it still doesn't work...

New Horizon 2009-12-29 04:18 PM

The AppleScript folder under Applications is empty. There is no Applescript Utility on my "Mac." I did a search and found nothing. I'm running the lastest version of Snow Leopard with all updates. I do have a Utilities directory under Applications where there is an AppleScript Editor.

New Horizon 2009-12-29 04:31 PM

... still working on it. Found out things changed in Snow Leopard: [url]http://www.macworld.com/article/142495/2009/08/snowleopardwhatsgonewhere.html[/url] .

New Horizon 2009-12-29 04:56 PM

Whpalmer4,

Thank you. I got it working. In Snow Leopard, AppleScript Editor handles what AppleScript Utility did before. Once past that your instructions got me going and I created a task outline with "Date due" and "Days overdue."

Now I'm off to learn AppleScript.

You are a big help. Thanks again.

whpalmer4 2009-12-29 05:33 PM

Glad you got it figured out -- I was on a Leopard-based system at the time and didn't realize the Script Utility had gone away (I've usually built those folders by hand).

For scripts relating to OO in particular, check out the Useful Scripts download in the Extras section of the OO webpage. Easier to see how to do some common manipulations that way than by learning all of AppleScript!

New Horizon 2009-12-31 01:36 AM

Because I'm learning AppleScript (currently novice) I will ask questions. Is it possible to run an AppleScript as a wrapper for an outline that also runs an AppleScript (like the one above) so as to appear (the script above) to run automatically?

In Unix one can create a "here" document/command/script that can supply arguments to and run an application. I'm wondering if something similar can be done with AppleScript, where the wrapper AppleScript runs OmniOutliner supplying the outline to run and which AppleScript in the outline to run too.

Thanks ... .


All times are GMT -8. The time now is 07:36 AM.

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