APSF function GetMagnification(telName as string, eyeName as string, aidName as string, doRound as boolean) as string dim mag as double mag = Magnification(Telescope(telName), Eyepiece(eyeName), VisualAid(aidName)) if doRound then if mag < 200 then dim dime, dimeFit, quarter, quarterFit as double dime = Round(mag / 10) * 10 dimeFit = Abs(mag - dime) quarter = Round(mag / 25) * 25 quarterFit = Abs(mag - quarter) if quarterFit < dimeFit then mag = quarter else mag = dime end if else mag = Round(mag / 25) * 25 end if end if // A little trick to get list sorting to work if mag < 10 then return " " + Format(mag, "#") elseif mag < 100 then return " " + Format(mag, "##") elseif mag < 1000 then return " " + Format(mag, "###") else return Format(mag, "####") end if end function function GetFilter(filterName as string) as string if filterName = "No Filter" then return "" else return filterName end if end function function GetAid(aidName as string) as string if aidName = "No Observing Aids" then return "" else return aidName end if end function function CurrentTelescopeIndex() as integer dim current as TelescopeResource current = CurrentTelescope if current = nil then current = DefaultTelescope end if if current = nil then return 1 end if dim i as integer for i = 1 to nTelescopes if Telescope(i).Name = current.Name then return i end if next return 1 end function function CurrentSiteIndex() as integer dim current as SiteResource current = CurrentSite if current = nil then current = DefaultSite end if if current = nil then return 1 end if dim i as integer for i = 1 to nSites if Site(i).Name = current.Name then return i end if next return 1 end function try // Be a good citizen // // Throw up a dialog to see if user wants to limit to specific telescopes/sites. // const telescopeCheckbox = "For Specific Telescope:" const telescopePopup = ".0" const siteCheckbox = "At Specific Site:" const sitePopup = ".1" const roundMagsCheckbox = "Round Magnifications" dim forTelescope, forSite as string, doRound as boolean SetBooleanParameter(telescopeCheckbox, nTelescopes > 0) SetPopupParameter(true, telescopePopup, CurrentTelescopeIndex() - 1, Telescopes) ParameterDependency(telescopePopup, telescopeCheckbox) SetBooleanParameter(siteCheckbox, nSites > 0) SetPopupParameter(true, sitePopup, CurrentSiteIndex() - 1, Sites) ParameterDependency(sitePopup, siteCheckbox) SetCaptionParameter("If options are not checked, report will be generated including all telescopes and/or sites.", _ 3, true, false, false, false, true) SetBooleanParameter(roundMagsCheckbox, true) SetCaptionParameter("Adaptive fit under 200; to nearest 25 elsewhere.", _ 2, true, false, false, false, true) if NOT EditParameters("Magnification Report") then exit end if if GetBooleanParameter(telescopeCheckbox) then forTelescope = GetPopupParameterAsString(telescopePopup) else forTelescope = "All Telescopes" end if if GetBooleanParameter(siteCheckbox) then forSite = GetPopupParameterAsString(sitePopup) else forSite = "All Sites" end if doRound = GetBooleanParameter(roundMagsCheckbox) // // Build a list to dump the results into. // dim list, row as integer list = NewList("Magnification Report for " + forTelescope + " at " + forSite) ListHeading(list, 1, "ID") ListHeading(list, 2, "Name") ListHeading(list, 3, "Type", 2) ListHeading(list, 4, "Magnification", 2) ListHeading(list, 5, "Seeing", 2) ListHeading(list, 6, "Eyepiece", 2) ListHeading(list, 7, "Filter", 2) ListHeading(list, 8, "Aid", 2) ListHeading(list, 9, "Observation Notes") row = 1 // // Go through the current plan's objects fetching global observations. // I'd rather have this go directly through the global observations, but there doesn't seem to be // a way to do this. // dim i as integer, obs as APGlobalObservation for i = 1 to nGlobalObservations obs = GlobalObservation(i) if forTelescope = "All Telescopes" OR obs.telescope = forTelescope then if forSite = "All Sites" OR obs.site = forSite then AddToList(list, row, 1, obs.ID) AddToList(list, row, 2, obs.Name) AddToList(list, row, 3, obs.Type) AddToList(list, row, 4, GetMagnification(obs.Telescope, obs.Eyepiece, obs.Aid, doRound)) AddToList(list, row, 5, obs.Seeing) AddToList(list, row, 6, obs.Eyepiece) AddToList(list, row, 7, GetFilter(obs.Filter)) AddToList(list, row, 8, GetAid(obs.Aid)) AddToList(list, row, 9, obs.Notes) row = row + 1 end if end if next if row = 1 then AddToList(list, row, 1, "No objects found using specified telescope and site.") end if catch print "My bad. Magnification Report script generated an exception." end try