Sub Main
' Program: GyroParse
' Source: ActivityOwner.com
' Copyright: http://creativecommons.org/licenses/by-sa/2.5/
'
' Description: This script takes the selected topic and uses the text to infer
' things like the duedate
'
' Disclaimer: This script is experimental and not highly tested. Use at your own
risk.
'
' Background: http://www.activityowner.com/2007/01/20/let-gyroq-read-your-mind/
'
' Revision history 1.00 1/20/07
'
'
'
Dim activity As Task
Dim activityStr As String
Set activity=ActiveDocument.Selection.PrimaryTopic.Task
activityStr=LCase(ActiveDocument.Selection.PrimaryTopic.Text)
' Context Parsing
If InStr(activityStr,"call") >0 Then
activity.Categories = "@phone"
ElseIf InStr(activityStr,"pick up")>0 Then
activity.Categories = "@errand"
ElseIf InStr(activityStr,"buy") >0 Then
activity.Categories = "@errand"
ElseIf InStr(activityStr,"read")>0 Then
activity.Categories = "@web"
End If
'Resourse Parsing
If InStr(activityStr,"waiting")>0 Then
activity.Resources = "Somebody Else"
End If
'Date Parsing
If InStr(activityStr,"today") >0 Then
activity.DueDate=Date
ElseIf InStr(activityStr,"tomorrow")>0 Then
activity.DueDate=Date+1
ElseIf InStr(activityStr,"next week")>0 Then
activity.DueDate=Date+7
ElseIf InStr(activityStr,"next month")>0 Then
activity.DueDate=DateAdd("m",1,Date)
ElseIf InStr(activityStr,"next year")>0 Then
activity.DueDate=DateAdd("yyyy",1,Date)
'
'End of week, month year parsing
'
ElseIf InStr(activityStr,"end of week")>0 And Weekday(Date)<7 Then
activity.DueDate=Date+6-Weekday(Now)
ElseIf InStr(activityStr,"end of week")>0 And Weekday(Date)=7 Then
activity.DueDate=Date+6
ElseIf InStr(activityStr,"end of month")>0 Then
activity.DueDate=DateAdd("m",1,Date)-Day(Date)-1
ElseIf InStr(activityStr,"end of year")>0 Then
activity.DueDate=DateSerial(Year(Date),12,31)
End If
'Priority Parse
If InStr(activityStr,"(P1)")>0 Then
activity.Priority=1
ElseIf InStr(activityStr,"(P2)")>0 Then
activity.Priority=2
ElseIf InStr(activityStr,"(P3)")>0 Then
activity.Priority=3
ElseIf InStr(activityStr,"(P4)")>0 Then
activity.Priority=3
End If
'Deadline Parse
If InStr(activityStr,"!")>0 Then
ActiveDocument.Selection.PrimaryTopic.Icons.AddStockIcon(mmStockIconExclamationMark)
End If
'Someday Parse
If InStr(activityStr,"someday")>0 Then
ActiveDocument.Selection.PrimaryTopic.Icons.AddStockIcon(mmStockIconHourglass)
End If
'Set start date to today by default and make it a task
activity.StartDate=Date
activity.Complete=0
End Sub