Next-action-verb-analysis-completed.mmbas

Option Explicit Sub Main Dim verbs(200) As String 'verbs found (1st words) Dim vc(200) As Integer	 'number of each verb Dim vlink(200) As String 'hyperlink for task associated with 1st occurance Dim tv As Integer 'number of 1st words found Dim uv As Integer 'number of unique 1st words found Dim uvmax As Integer 'maximum number of occurrences of a unique 1st word Dim i,j As Integer 'loop counters Dim ctopic, ytopic, mtopic,dtopic As Topic 'main, year, month, day topics Dim sstopic As Topic 'action item topic under each context Dim reporttopic, reportsubtopic, reportsubsubtopic As Topic 'report map topic Dim na As String 'next action string Dim eow As Integer 'location of 1st space in next action string Dim fw As String 'first word in next action string Dim found As Boolean 'verb already seen Dim report As Document 'report map Dim s, f As String 'name for source and report maps Dim doc As Document ' source map

Debug.Clear uv=0 tv=0 s = GetPath(mmDirectoryMyMaps) & "Completedlog.mmap" f = GetPath(mmDirectoryMyMaps) & "FirstWordReport.mmap" Set doc=Documents.Open(s) For Each ctopic In doc.CentralTopic.AllSubTopics For Each ytopic In ctopic.AllSubTopics For Each mtopic In ytopic.AllSubTopics For Each dtopic In mtopic.AllSubTopics For Each sstopic In dtopic.AllSubTopics na=LCase(sstopic.Text) eow=InStr(na," ") If eow>0 Then fw=Mid(na,1,eow-1) Else fw=na End If	       		  	tv=tv+1 found=False If uv>0 Then For i=1 To uv		         				If fw=verbs(i) Then vc(i)=vc(i)+1 found=True End If	         				Next End If   	   				If Not found Then uv=uv+1 verbs(uv)=fw vc(uv)=1 'vlink(uv)=sstopic.Hyperlink.Address End If		    	Next Next Next Next Next uvmax=0 For i=1 To uv	 	If vc(i)>uvmax Then uvmax=vc(i) Next On Error GoTo X	Set report=Documents.Open(f) If Err.Number>0 Then X: Err.Clear Set report=Documents.Add report.SaveAs(f) End If	On Error GoTo 0 Set reporttopic= report.CentralTopic.AddSubTopic(Now & " : "&Str(uv) & " unique 1st words") For i= uvmax To 1 Step -1 Set reportsubtopic = reporttopic.AddSubTopic(Str(i)) For j=1 To uv		   If i=vc(j) Then Set reportsubsubtopic = reportsubtopic.AddSubTopic(verbs(j)) 'reportsubsubtopic.CreateHyperlink(vlink(j)) End If		Next If reportsubtopic.AllSubTopics.Count=0 Then reportsubtopic.Delete End If	Next report.Save End Sub