Naaa code

From ActivityOwnerWiki
Revision as of 15:25, 4 November 2007 by Activityowner (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
{run:macro:'Dim actions(500) As Topic%0D%0A	Dim age(500) As Integer%0D%0A	Dim n As Integer%0D%0A	Dim mtopic As Topic%0D%0A	Dim stopic As Topic%0D%0A	Dim sstopic As Topic%0D%0A	Dim ssstopic As Topic%0D%0A	Dim sssstopic As Topic%0D%0A	Dim swap As Topic%0D%0A	Dim swapa As Integer%0D%0A	Dim nadoc As Document%0D%0A	Dim i As Integer%0D%0A	Dim j As Integer%0D%0A	Dim avg As Double%0D%0A	Dim found As Boolean%0D%0A	Dim doc As Document%0D%0A	Set nadoc=ActiveDocument%0D%0A	found=False%0D%0A    For Each mtopic In nadoc.CentralTopic.AllSubTopics%0D%0A    	If LCase(mtopic.Text)=LCase(%22My committed Next actions towards success%22) Then%0D%0A    		found=True%0D%0A			For Each stopic In mtopic.AllSubTopics%0D%0A		    		For Each sstopic In stopic.AllSubTopics%0D%0A	       		 		If sstopic.Task.StartDate>0 And sstopic.Task.Complete<100 Then%0D%0A	       		 		   n=n+1%0D%0A	       		 		   Set actions(n)=sstopic%0D%0A	       		 		   age(n)=Now-sstopic.Task.StartDate%0D%0A	       		 		End If%0D%0A	       		 		If sstopic.AllSubTopics.Count>0 Then%0D%0A	       		 			For Each ssstopic In sstopic.AllSubTopics%0D%0A								If ssstopic.Task.StartDate>0 And sstopic.Task.Complete<100 Then%0D%0A	       		 		   			n=n+1%0D%0A	       		 		   			Set actions(n)=ssstopic%0D%0A	       		 		   			age(n)=Now-ssstopic.Task.StartDate%0D%0A	       		 				End If%0D%0A	       		 				If ssstopic.AllSubTopics.Count>0 And sstopic.Task.Complete<100 Then%0D%0A	       		 					For Each sssstopic In ssstopic.AllSubTopics%0D%0A										If sssstopic.Task.StartDate>0 Then%0D%0A	       		 		   					n=n+1%0D%0A	       		 		   					Set actions(n)=sssstopic%0D%0A	       		 		   					age(n)=Now-sssstopic.Task.StartDate%0D%0A	       		 						End If%0D%0A	       		 					Next%0D%0A	       		 				End If%0D%0A	       		 			Next%0D%0A	       		 		End If%0D%0A		     		Next%0D%0A	 		Next%0D%0A		End If%0D%0A	Next%0D%0A	If Not found Then%0D%0A		MsgBox(%22next action branch Not found%22)%0D%0A		End%0D%0A	End If%0D%0A	For i=1 To n-1%0D%0A      For j=i+1 To  n%0D%0A         If age(i)<age(j) Then%0D%0A            Set swap=actions(i)%0D%0A        	Set actions(i)=actions(j)%0D%0A            Set actions(j)=swap%0D%0A            swapa = age(i)%0D%0A            age(i)=age(j)%0D%0A            age(j)=swapa%0D%0A          End If%0D%0A      Next%0D%0A    Next%0D%0A    avg=0%0D%0A	For i=1 To n%0D%0A		avg=avg+age(i)/n%0D%0A	Next%0D%0A	Set mtopic=nadoc.CentralTopic.AddBalancedSubTopic(%22Your %22 & n & %22 dated next actions average %22 & Round(avg) & %22 days old.%22 & Chr(10) & %22 They have been around for a grand total of %22 & Round(n*avg/365,1) & %22 years!.%22)%0D%0A	Set stopic = mtopic.AddSubTopic(%22Oldest%22)%0D%0A	For i=1 To Round(0.1*n)%0D%0A		Set sstopic = stopic.AddSubTopic(Str(age(i)))%0D%0A		Set ssstopic=sstopic.AddSubTopic(%22%22)%0D%0A		ssstopic.Xml= actions(i).Xml%0D%0A	Next%0D%0A	Set stopic=mtopic.AddSubTopic(%22Youngest%22)%0D%0A	For i= Round(0.9*n) To n%0D%0A		Set sstopic = stopic.AddSubTopic(Str(age(i)))%0D%0A		Set ssstopic=sstopic.AddSubTopic(%22%22)%0D%0A		ssstopic.Xml= actions(i).Xml%0D%0A	Next%0D%0A	Set stopic=mtopic.AddSubTopic(%22Random Activity of the Day%22)%0D%0A	Set sstopic = stopic.AddSubTopic(%22%22)%0D%0A	sstopic.Xml = actions(Round(Rnd*(n-1))+1).Xml'}