'
' Convert AAVSO Star Positions file (Part 1) to tab-delimited
' and convert coordinates to decimal degrees (both RA & Dec)
'
Option Explicit

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

Dim TAB, FSO, U, Buf, PosStream, TabStream

TAB = Chr(9)
Set U = CreateObject("DriverHelper.Util")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set PosStream = FSO.OpenTextFile(ROOT & "Latest Data from AAVSO\aavsostarpositions-j2k.txt")
Set TabStream = FSO.CreateTextFile(ROOT & "aavsostarpositions-j2k-tab.txt")

Do While Not PosStream.AtEndOfStream
	Buf = PosStream.ReadLine()
	'
	' Do not write stars with no positions
	'
	If Len(Buf) > 23 Then									' Something beyond Name
		TabStream.Write Trim(Mid(Buf, 1, 10)) & TAB		' Harvard/AAVSO designation
		TabStream.Write Trim(Mid(Buf, 11, 12)) & TAB	' Name
		TabStream.Write U.HMSToDegrees(Trim(Mid(Buf, 24, 12))) & TAB	' RA
		TabStream.Write U.DMSToDegrees(Trim(Mid(Buf, 37))) & VbCrLf		' Dec
	End If
Loop
PosStream.Close
TabStream.Close

	
