Map2Outline.mmbas

'ao_map2outline 29Dec2009 http://creativecommons.org/licenses/by-nc-nd/3.0/ '#uses "ao_common.mmbas" Option Explicit Sub Main Dim parent As Topic Dim t As Topic Dim f As String Dim indent As Integer indent=0 If ActiveDocument.Selection.Count>0 Then Set parent=ActiveDocument.Selection.PrimaryTopic Else Set parent=ActiveDocument.CentralTopic End If	f=Replace(parent.Document.FullName,".mmap",".html") Open f For Output As #1 Print #1, " " Print #1, parent.Text For Each t In parent.AllSubTopics exportinfo t,indent Next Print #1, " " Close #1 On Error Resume Next Shell("C:\Program Files\Internet Explorer\iexplore.exe "&f,1) Set parent=Nothing Set t=Nothing End Sub Function hyperlinkstring(ByRef t As Topic) As String If t.HasHyperlink Then hyperlinkstring="" & t.Text & "" Else hyperlinkstring="" & t.Text & "" End If End Function Sub exportinfo(ByRef t As Topic, ByVal indent As Integer) Dim st As Topic Dim i As Integer If indent>0 Then For i=1 To indent Print #1, " " Next Else Print #1, " " End If   Print #1, hyperlinkstring(t) & " " & vbCrLf indent=indent+1 For Each st In t.AllSubTopics exportinfo st, indent Next Set st=Nothing End Sub