APSF //- Import AAVSO Bulletin 70 Month-by-Month files //- //- //- Note: only works with text files downloaded from the //- "Bulletin 70 Month-by-month" section. //- Requires that GCVS catalogue is installed. //- //- Paul Rodman, Feb 2008 //- //- V1.0 20 Feb 2008 //- Initial Release //----------------------------------------------------------------------------- function GetSortKey(s as string, key as integer) as string dim ss(-1),c,d as string, i as integer select case key case 0 // R.A. return mid(s,2,4) case 1 // Dec return mid(s,6,3) case 2 // Constellation ss=Split(trim(mid(s,11,14))," ") return ss(ubound(ss)) case 3 // Date c=trim(mid(s,50,2)) while len(c)<2 c="0"+c wend return c case 4 // Magnitude at maximum c="" for i=26 to 32 d=mid(s,i,1) if IsNumeric(d) or d="." then c=c+d next while len(c)<4 c="0"+c wend return c case 5 // Magnitude at minimum c="" for i=34 to 41 d=mid(s,i,1) if IsNumeric(d) or d="." then c=c+d next while len(c)<4 c="0"+c wend return c end select end function //----------------------------------------------------------------------------- dim infile as APTextFile dim isReading as boolean dim s,oblist(-1),smonth,syear,fields(-1),a,b,id as string dim sortBy,i,j,chosen(-1),aavsoID,aavsoOther,aavsoDate as integer dim srch as APSearch dim cobj as APPlanObject // Open bulletin file (File has name BULmmmyy.txt, // where mmm is month and yy is year) infile=ReadTextFile if infile=nil then return // Read in the objects isReading=false while not infile.EOF s=infile.ReadLine if not isReading then if instr(s,"MAXIMA")>0 and instr(s,"minima")>0 then isReading=true // Extract date fields=Split(s," ") smonth=fields(ubound(fields)-1) syear=fields(ubound(fields)) end if else if trim(s)="" then exit if len(s)>=50 then oblist.Append s end if wend infile.Close // Choose sort order SetChoiceParameter("Sort Order",sortBy,"R.A.","Dec","Constellation","Date","Magnitude at maximum", _ "Magnitude at minimum") redim fields(-1) fields.Append "Ignore" for i=1 to 4 a="User Field "+str(i) if UserHeading(i)<>a then a=a+" ("+UserHeading(i)+")" fields.Append a next fields.Append "ID" fields.Append "Name" SetPopupParameter("Add AAVSO ID",aavsoID,fields) redim fields(-1) fields.Append "Ignore" for i=1 to 4 a="User Field "+str(i) if UserHeading(i)<>a then a=a+" ("+UserHeading(i)+")" fields.Append a next fields.Append "Replace Notes" fields.Append "Append to Notes" SetPopupParameter("Add Date",aavsoDate,fields) redim fields(-1) fields.Append "Ignore" for i=1 to 4 a="User Field "+str(i) if UserHeading(i)<>a then a=a+" ("+UserHeading(i)+")" fields.Append a next fields.Append "Replace Notes" fields.Append "Append to Notes" SetPopupParameter("Add other info",aavsoOther,fields) if not EditParameters("Select sort order") then return sortBy=GetChoiceParameter("Sort Order") aavsoID=GetPopupParameter("Add AAVSO ID") aavsoDate=GetPopupParameter("Add Date") aavsoOther=GetPopupParameter("Add other info") // Sort if sortBy<>0 then for i=ubound(oblist) downto 1 for j=0 to i-1 a=GetSortKey(oblist(j),sortBy) b=GetSortKey(oblist(j+1),sortBy) if a>b then s=oblist(j) oblist(j)=oblist(j+1) oblist(j+1)=s end if next next end if // Select the ones we want to import redim chosen(ubound(oblist)) SetCheckListParameter("AAVSO Stars",chosen,oblist,false,30) if not EditParameters("Select sort order") then return chosen=GetCheckListParameter("AAVSO Stars") // Add the selected objects to the plan for i=0 to ubound(oblist) if chosen(i)<>0 then // Look up the ID in the GCVS id=ReplaceAll(trim(mid(oblist(i),10,15))," "," ") srch = new APSearch srch.SetCatalog("GCVS") if srch.Search(id) then if srch.nObjects>0 then cobj=srch.GetObject(1).AddToPlan a=trim(mid(oblist(i),2,8)) select case aavsoID case 1 to 4 cobj.User(aavsoID)=a case 5 cobj.ID=a case 6 cobj.Name=a end select a=trim(mid(oblist(i),50,2)) while len(a)<2 a="0"+a wend a=mid(oblist(i),46,4)+a select case aavsoDate case 1 to 4 cobj.User(aavsoDate)=a case 5 cobj.Notes="Date: "+a case 6 if cobj.Notes="" then cobj.Notes="Date: "+a else cobj.Notes=cobj.Notes+". Date: "+a end select a=trim(oblist(i)) while instr(a," ")>0 a=ReplaceAll(a," "," ") wend select case aavsoOther case 1 to 4 cobj.User(aavsoOther)=a case 5 cobj.Notes=a case 6 if cobj.Notes="" then cobj.Notes=a else cobj.Notes=cobj.Notes+". ["+a+"]" end select end if end if end if next Bleep