'
' Convert AAVSO Validation file (Part 1) to tab-delimited
'
Option Explicit

Const ROOT = "E:\StarryNight Catalogs\AAVSO Names and Markers\"

Dim TAB, FSO, Buf, Range, ValStream, TabStream

TAB = Chr(9)
Set FSO = CreateObject("Scripting.FileSystemObject")
Set ValStream = FSO.OpenTextFile(ROOT & "Latest Data from AAVSO\vallong-part1.txt")
Set TabStream = FSO.CreateTextFile(ROOT & "vallong-part1-tab.txt")

Do While Not ValStream.AtEndOfStream
	Buf = ValStream.ReadLine()
	'
	' Do not write stars with no range
	'
	If Len(Buf) > 32 Then									' Something beyond Type
		Range = Trim(Mid(Buf, 33, 14))
		If Range <> "" Then
			TabStream.Write Trim(Mid(Buf, 1, 10)) & TAB		' Harvard/AAVSO designation
			TabStream.Write Trim(Mid(Buf, 11, 12)) & TAB	' Name
			TabStream.Write Trim(Mid(Buf, 23, 10)) & TAB	' Type
			TabStream.Write Range & TAB
			If Len(Buf) > 47 Then TabStream.Write Trim(Mid(Buf, 48, 8))	' Period
			TabStream.Write TAB
			If Len(Buf) > 55 Then TabStream.Write Trim(Mid(Buf, 56))	' Spectrumn/AltName/Comment
			TabStream.Write VbCrLf
		End If
	End If
Loop
ValStream.Close
TabStream.Close

	
