GyroQReader.mmbas

From ActivityOwnerWiki
Jump to: navigation, search
Option Explicit
'Read GyroQ.ini file and create a new main topic on current map with tags as subtopics
'http://www.activityowner.com http://creativecommons.org/licenses/by-sa/2.5/
'Note that all control characters may not be converted
'The conversion has not been extensively tested so tags could be corrupted -- use at own risk
Sub Main
  Dim ignore, tagname, sequence As String
  Dim mtopic, ttopic As Topic
  Dim i As Integer
  Open GetPath(mmDirectoryMyMaps) & "GyroQ\gyroq.ini" For Input As #1
  Set mtopic = ActiveDocument.CentralTopic.AddSubTopic("Tag Backup " & Date)
  Input #1, ignore, ignore
  For i=0 To 20
     Input #1, ignore, tagname,ignore, sequence,ignore
     tagname=Mid(tagname,8,Len(tagname))
     sequence=Mid(sequence,12,Len(sequence))
     sequence=Replace(sequence,"%7B","{")
	 sequence=Replace(sequence,"%7D","}")
	 sequence=Replace(sequence,"%3B",";")
	 sequence=Replace(sequence,"%0D",Chr(13))
	 sequence=Replace(sequence,"%0A",Chr(10))
	 sequence=Replace(sequence,"%5C","\")
	 sequence=Replace(sequence,"%20"," ")
	 sequence=Replace(sequence,"%3A",":")
	 sequence=Replace(sequence,"%3D","=")
	 sequence=Replace(sequence,"%23","#")
	 sequence=Replace(sequence,"%5E","^")
	 sequence=Replace(sequence,"7E","!")
	 sequence=Replace(sequence,"%25","%")
	 sequence=Replace(sequence,"%2C",",")
	 sequence=Replace(sequence,"%40","@")
	 sequence=Replace(sequence,"%2F","/")
	 sequence=Replace(sequence,"%7C","|")
	 sequence=Replace(sequence,"%22",Chr(34))
	 sequence=Replace(sequence,"%26","&")
	 sequence=Replace(sequence,"%3F","?")
	 sequence=Replace(sequence,"%3C","<")
	 sequence=Replace(sequence,"%2B","+")
     Set ttopic = mtopic.AddSubTopic(tagname)
	 ttopic.Notes.Text = sequence
  Next
End Sub