APSF //################################################################################################################################## // Name : SimbadQuery // Purpose : Retrieve object information from the Simbad database // Requires: AP v1.5.4 or later // Author : Robin Lauryssen-Mitchell // Date : 19Sep2006 // Version : 2.2 // Status : Production // History : 20060801 - 0.1 - Internal testing only // 20060801 - 1.0 - Production release // 20060801 - 1.1 - Minor update (insert Object.ID at head of list) // 20060801 - 2.0 - Added search by RA/Dec feature // 20060919 - 2.1 - Added multi-object support // 20061124 - 2.2 - Replaced the Shell call to load a browser with an OpenURL call // Added 'Search Radius' // Added 'Biblographic Search' parameters // 20070106 - 3.0 - Total rewrite - not much of the original left except for the idea! // Notes : - This will not work with all selected names by a long shot // - Objects with prefixes such as SAO, HD and HR seem to work best // - Selecting to search by RA/Dec overrides the selected object name // - The script uses an extremely simplified set of the Simbad search arguments. In fact only the Ident key is used, // all others are left at default. Maybe a future version could have more. // - IMPORTANT: Using RA/Dec may create huge Simbad reports // - My own copy of this script has cRadiusDef = 15 to match(ish) the downloaded DSS images (30'x30') // - The biblographic search feature may not be that useful since a link is provided by Simbad in any case // Just wanted to see if I could make it work :) // Issues : Has not been tested with objects that have no Name/s //################################################################################################################################## //----- Start of included Library Scripts //----- Library Script: lib_AP //################################################################################################################################## // Name : AP_Library // Purpose : Library to support AP scripts. // The use of this library (particularly the constants) is intended to improve the readability of AP scripts. // For example, instead of: // if ObjectIndex = -1 then ... // you could write // if ObjectIndex = cNoSelectedObject then ... // Requires: AP v1.5.1b3 or later // Author : Robin Lauryssen-Mitchell // Date : 14th September 2006 // Version : 1.2 // Status : Production // History : 08Aug06 - 0.1 - Initial beta release // 21Aug06 - 0.2 - Changed name from AP_Constants to AP_Declarations // 22Aug06 - 0.3 - Added prefixes to declarations // 27Aug06 - 0.4 - Changed name to AP_Library - and changed it back again when the routines stopped working!!! // 11Sep06 - 1.1 - Added Double-Click constants for SetListParameter etc // 14Sep06 - 1.2 - Added WindowStatus, // Notes : - Must get approval from Paul before posting this. Might be thought of as an 'official' part of AP due to the filename // Perhaps get some of these (constants) included in the APCallable module // - References to the Scripting Manual are correct as of v1.5.1b3 (I hope) // - Some of the constant name prefixes are a little clumsy (e.g. APTF for APTextFile), however, they are added in an // attempt to avoid conflicting with another script writers declarations. Occasionally it got too much, even for me. // For example, what should have been the prefix cAPAAVSO got abbreviated to cAPA. The whole Prefix question, // including the leading 'c' is up for debate, censure, veto, whatever. BTW, the leading 'c' is a left-over from a // Microsoft program documentation standard - not sure if even they still use it!!! // - Prefixes // Format = AP?? where AP=AstroPlanner and ??=1 or a 2-letter section designator // Section Title Prefix Notes // ------- --------------------------- ------ ------------------------------------ // 2.2 General Properties APGP // 2.3 General Methods APGM Constellation constants not prefixed // 2.3.24 EditParameters APEP // 2.4 APPlanObject APO // 2.5 APObservation APOB // 2.6 APAAVSO APA // 2.7 APCatalogObject APCO // 2.8 APCatalog APC // 2.9 APTextFile APTF // 2.10 APSearch APS // 2.11 Canvas APCV // 2.11.4 CanvasFOV APCF // 2.11.5 Creating and drawing tables APCT // 2.12 Table APT // 2.13 Resources APR // 2.13.2 SiteResource APSR // 2.13.3 TelescopeResource APTR // 2.13.4 EyepieceResource APER // 2.13.5 VisualAidResource APVR // 2.14 Serial port support APSP // - Still not convinced that the Prefixes are a good idea - feels a little clumsy to me // - Have abandoned, for the time being, the idea of including 'standard' variable declarations in this library. // For the time being this file will only contain Constants and a few routines. //################################################################################################################################## //================================================================================================================================== // Declarations //================================================================================================================================== //---------------------------------------------------------------------------------------------------------------------------------- // Scripting constants //---------------------------------------------------------------------------------------------------------------------------------- //.................................................................................................................................. // 2.2 General Properties (APGP) //.................................................................................................................................. //General purpose const cAPGP_CancelledYes = true //User clicked a 'Cancel' button const cAPGP_CancelledNo = false //User did not click a 'Cancel' button //Object const cAPGP_NoSelectedObject = -1 //Plan does not contain a selected object const cAPGP_NoObject = 0 //Plan contains no objects const cAPGP_MinObject = 1 //Base object ID //Plan const cAPGP_MissingPlan = -1 //No plan (usually with given name) was loadable const cAPGP_NoPlan = 0 //No plan (usually with given name) is loaded const cAPGP_MinPlan = 1 //Base plan ID const cAPGP_PlanFileExt = ".apd" //AP plan file extension //Catalogue const cAPGP_MinCatalog = 1 //Base catalogue ID //Telescope const cAPGP_CurrentRAOffline = -999 //RA value returned if scope is offline const cAPGP_CurrentDecOffline = -999 //Dec value returned if scope is offline const cAPGP_ScopeIsOffline = false //Value return by IsOnline if scope is offline const cAPGP_ScopeIsOnline = true //Value return by IsOnline if scope is online //User Heading const cAPGP_UserColumn1 = 1 //Index for User column 1 const cAPGP_UserColumn2 = 2 //Index for User column 2 const cAPGP_UserColumn3 = 3 //Index for User column 3 const cAPGP_UserColumn4 = 4 //Index for User column 4 //User Abort const cAPGP_AbortNo = false //Operation was not cancelled by user const cAPGP_AbortYes = true //Operation was cancelled by user //PlanLocalDateTime const cAPGP_UseComputerTime = 0 //Set the local date/time to the computer date/time //Plan Dates const cAPGP_MinPlanTime = 0.0 //Minimum GMT/GMTST/LST time const cAPGP_MaxPlanTime = 23.999999 //Maximum GMT/GMTST/LST time //.................................................................................................................................. // 2.3 General Methods (APGM) //.................................................................................................................................. //List const cAPGM_MinList = 1 //Base list ID const cAPGM_MinListRow = 1 //Base list row ID const cAPGM_MinListCol = 1 //Base list column ID const cAPGM_ListHeadingDef = 0 //Heading justification is Default const cAPGM_ListHeadingLeft = 1 //Heading justification is Left const cAPGM_ListHeadingCentre = 2 //Heading justification is Centre const cAPGM_ListHeadingRight = 3 //Heading justification is Right //SlewTo const cAPGM_SlewToNotConnected = -1 //Telescope is not connected or not GoTo capable const cAPGM_SlewToOK = 0 //Slew successful const cAPGM_SlewToBelowHorizon = 1 //Below horizon const cAPGM_SlewToOutsideLimits = 2 //Outside slewing limits const cAPGM_SlewToBlocked = 3 //Blocked by user-defined horizon //CatalogFindID const cAPGM_CatalogNotFound = 0 //Catalogue search was not successful const cAPGM_MinCatalogFound = 1 //Minimum catalogue find ID //GetCatalog const cAPGM_GetCatalogFailed = nil //Catalogue ID or Name could not be found //2.3.9 Choice const cAPGM_MinChoice = 1 //Base Choice ID const cAPGM_ChoiceCancelled = -1 //User clicked 'Cancel' //2.3.10 Options const cAPGM_MinOption = 1 //Base Option ID const cAPGM_OptionCancelled = -1 //User clicked 'Cancel' //TextFile const cAPGM_TextFileFailed = nil //Operation failed or user clicked 'Cancel' const cAPGM_ScriptFileExt = ".txt" //Script filename extension //Launch const cAPGM_AppForeground = true //Try to put the application in the foreground when launched //Shell const cAPGM_ShellMinTimeout = 0 //When would this ever be used!? const cAPGM_ShellDefTimeout = 2000 //Default timeout - 2000ms or 2 seconds //FindObject const cAPGM_FindObjectFailed = nil //FindObject search failed //EditParameters (see section 2.3.24 below) //UserColumnNumeric const cAPGM_UserDecPlaces0 = 0 //Display 0 decimal places const cAPGM_UserDecPlaces1 = 1 //Display 1 decimal place const cAPGM_UserDecPlaces2 = 2 //Display 2 decimal places const cAPGM_UserDecPlaces3 = 3 //Display 3 decimal places const cAPGM_UserDecPlaces4 = 4 //Display 4 decimal places const cAPGM_UserDecPlacesAuto = -1 //Automatically select number of decimal places //[Get|Set]ExternalCoords const cAPGM_ExternalCoordsOK = true //External application returned a set of coordinates const cAPGM_ExternalCoordsFailed = false //External application could not return coordinates for some reason //GetURL const cAPGM_URLTimeoutNever = 0 //Sets the function to never timeout const cAPGM_URLTimeoutDef = 30 //Default timeout const cAPGM_URLEmpty = "" //Returned if error occurrs //SortObservingList const cAPGM_AscendingOrder = true //Sort into ascending order const cAPGM_DescendingOrder = false //Sort into descending order //GetPlanName, PlanChanged, SavePlan, ClosePlan const cAPGM_CurrentlySelectedPlan = -1 //Get the currently selected plan name //GetPlanNumber const cAPGM_PlanNumberNotFound = 0 //The named plan is not currently loaded //PlanChanged const cAPGM_PlanHasChanged = true //Plan has been changed since last save const cAPGM_PlanNotChanged = false //Plan has not been changed since last save //ClosePlan const cAPGM_PlanSilentCloseOff = true //Avoid the user alert if the plan is 'dirty' const cAPGM_PlanSilentCloseOn = false //Raise the user alert if the plan is 'dirty' //NewPlan const cAPGM_NewPlanOverwriteAlertOff = true //Do not raise a file overwrite alert const cAPGM_NewPlanOverwriteAlertOn = false //Raise a file overwrite alert if needed const cAPGM_NewPlanUniqueOn = true //Auto-generate unique file name suffix if needed const cAPGM_NewPlanUniqueOff = false //Do not generate a unique file name suffix if file name already exists const cAPGM_NewPlanCancelled = 0 //User cancelled the operation const cAPGM_NewPlanBadFileName = -1 //Specified path does not make sense for some reason const cAPGM_NewPlanPathIsFolder = -2 //Specified path is a folder const cAPGM_NewPlanProtectedFile = -3 //Plan file could not be deleted const cAPGM_NewPlanFileIsOpen = -4 //Plan with same name is already open const cAPGM_NewPlanCreationFailed = -5 //Plan could not be created //OpenPlan const cAPGM_OpenPlanFailed = -1 //Plan file could not be opened for some reason (usually a bad path specification) //StartProgress const cAPGM_StartProgressCancelOn = true //Display a cancel button const cAPGM_StartProgressCancelOff = false //Do not display a cancel button //UpdateProgress const cAPGM_UpdateProgressCancelled = true //Cancel button was clicked const cAPGM_UpdateProgressRunning = false //Cancel button not clicked //Format[RA|Dec] const cAPGM_FormatExtendedOn = true //Enable decimal second representation const cAPGM_FormatExtendedOff = false //Disable decimal second representation //FormatRA const cAPGM_RAMin = 0.0 //Minimum RA value const cAPGM_RAMax = 23.9999 //Maximum RA value const cAPGM_RADefault = "hms:" //The default RA format const cAPGM_RALong = "hmsa" //The longest RA format available const cAPGM_RAShort = "hms" //The shortest RA format available const cAPGM_RADecimal = "h" //Express the RA value as a decimal //FormatDec const cAPGM_DecMin = -90.0 //Minimum Dec value const cAPGM_DecMax = 90.0 //Maximum Dec value const cAPGM_DecDefault = "+dmsx" //The default Dec format const cAPGM_DecLong = "+dmsa" //Longest format (could have been '+dmsx', but I chose this version to match the long RA format) const cAPGM_DecShort = "dms" //Shortest Dec format available const cAPGM_DecDecimal = "d" //Express the Dec value as a decimal //OKCancel const cAPGM_DefaultOKButton = true //OK button is the default const cAPGM_DefaultCancelButton = false //Cancel button is the default const cAPGM_OKButtonClicked = true //The OK button was clicked const cAPGM_CancelButtonClicked = false //The Cancel button was clicked //YesNo const cAPGM_DefaultYesButton = true //Yes button is the default const cAPGM_DefaultNoButton = false //No button is the default const cAPGM_YesButtonClicked = true //Yes button was clicked const cAPGM_NoButtonClicked = false //No button was clicked //Confirmation const cAPGM_DefaultButton1 = true //Button 1 is the default const cAPGM_DefaultButton2 = false //Button 2 is the default const cAPGM_Button1Clicked = true //Button 1 was clicked const cAPGM_Button2Clicked = false //Button 2 was clicked //Constellations const cAnd = 0 const cAnt = 1 const cAps = 2 const cAql = 3 const cAqr = 4 const cAra = 5 const cAri = 6 const cAur = 7 const cBoo = 8 const cCae = 9 const cCam = 10 const cCap = 11 const cCar = 12 const cCas = 13 const cCen = 14 const cCep = 15 const cCet = 16 const cCha = 17 const cCir = 18 const cCMa = 19 const cCMi = 20 const cCnc = 21 const cCol = 22 const cCom = 23 const cCrA = 24 const cCrB = 25 const cCrt = 26 const cCru = 27 const cCrv = 28 const cCVn = 29 const cCyg = 30 const cDel = 31 const cDor = 32 const cDra = 33 const cEqu = 34 const cEri = 35 const cFor = 36 const cGem = 37 const cGru = 38 const cHer = 39 const cHor = 40 const cHya = 41 const cHyi = 42 const cInd = 43 const cLac = 44 const cLeo = 45 const cLep = 46 const cLib = 47 const cLMi = 48 const cLup = 49 const cLyn = 50 const cLyr = 51 const cMen = 52 const cMic = 53 const cMon = 54 const cMus = 55 const cNor = 56 const cOct = 57 const cOph = 58 const cOri = 59 const cPav = 60 const cPeg = 61 const cPer = 62 const cPhe = 63 const cPic = 64 const cPsA = 65 const cPsc = 66 const cPup = 67 const cPyx = 68 const cRet = 69 const cScl = 70 const cSco = 71 const cSct = 72 const cSer = 73 const cSex = 74 const cSge = 75 const cSgr = 76 const cTau = 77 const cTel = 78 const cTrA = 79 const cTri = 80 const cTuc = 81 const cUMa = 82 const cUMi = 83 const cVel = 84 const cVir = 85 const cVol = 86 const cVul = 87 const cAndromeda = 0 const cAntlia = 1 const cApus = 2 const cAquila = 3 const cAquarius = 4 const cAra = 5 const cAries = 6 const cAuriga = 7 const cBootes = 8 const cCaelum = 9 const cCamelopardis = 10 const cCapricornus = 11 const cCarina = 12 const cCassiopeia = 13 const cCentaurus = 14 const cCepheus = 15 const cCetus = 16 const cChamaeleon = 17 const cCircinus = 18 const cCanisMajor = 19 const cCanisMinor = 20 const cCancer = 21 const cColumba = 22 const cComaBerenices = 23 const cCoronaAustralis = 24 const cCoronaBorealis = 25 const cCrater = 26 const cCrux = 27 const cCorvus = 28 const cCanesVenatici = 29 const cCygnus = 30 const cDelphinus = 31 const cDorado = 32 const cDraco = 33 const cEquuleus = 34 const cEridanus = 35 const cFornax = 36 const cGemini = 37 const cGrus = 38 const cHercules = 39 const cHorologium = 40 const cHydra = 41 const cHydrus = 42 const cIndus = 43 const cLacerta = 44 const cLeo = 45 const cLepus = 46 const cLibra = 47 const cLeoMinor = 48 const cLupus = 49 const cLynx = 50 const cLyra = 51 const cMensa = 52 const cMicroscopium = 53 const cMonoceros = 54 const cMusca = 55 const cNorma = 56 const cOctans = 57 const cOphiuchus = 58 const cOrion = 59 const cPavo = 60 const cPegasus = 61 const cPerseus = 62 const cPhoenix = 63 const cPictor = 64 const cPiscesAustrinus = 65 const cPisces = 66 const cPuppis = 67 const cPyxis = 68 const cReticulum = 69 const cSculptor = 70 const cScorpius = 71 const cScutum = 72 const cSerpens = 73 const cSextans = 74 const cSagitta = 75 const cSagittarius = 76 const cTaurus = 77 const cTelescopium = 78 const cTriangulumAustrale = 79 const cTriangulum = 80 const cTucana = 81 const cUrsaMajor = 82 const cUrsaMinor = 83 const cVela = 84 const cVirgo = 85 const cVolans = 86 const cVulpecula = 87 const cConstellationNone = -1 const cConstellationMin = 0 const cConstellationMax = 87 //Additional non-ScriptingManual declarations const cConstellationSep = " - " const cConstellationShortName = 1 const cConstellationLongName = 2 //2.3.70 ScreenSize const cAPGM_PhysicalScreen = true //Real screen size const cAPGM_AvailableScreen = false //Takeing into account screen menus, docks etc //2.3.71-74 Main Window States (Windows only) const cAPGM_MainWindowMinimized = -1 const cAPGM_MainWindowNormal = 0 const cAPGM_MainWindowMaximized = 1 //.................................................................................................................................. // 2.3.24 EditParameters (APEP) //.................................................................................................................................. const cAPEP_UserCancelled = -1 //User cancel flag value (should replace this - darn! can't remember why!!!) const cAPEP_ShowFieldIndices = true //Reveal the field ID and Tab numbers const cAPEP_HideFieldIndices = false //Hide the field ID and Tab numbers // [Get|Set]XXXParameter //General const cAPEP_FieldAppendOn = true //Put field in next column to right const cAPEP_FieldAppendOff = false //Put field in next row down const cAPEP_FieldIndexSep = "." //Field label format Index separator const cAPEP_FieldTabSep = ":" //Field label format Tab separator //String const cAPEP_StringMultilineOn = true const cAPEP_StringMultilineOff = false //Choice const cAPEP_ChoiceDisablePrefix = "!" //PopUp, ListChoice const cAPEP_ListSortedOff = false //Display list in 'loaded' order const cAPEP_ListSortedOn = true //Display list in alpha sorted order const cAPEP_ListMaxVisibleDef = 6 //Default number of list entries visible const cAPEP_DblClickOn = true //Allow double-click = OK const cAPEP_DblClickOff = false //Disable double-click = OK //CheckList const cAPEP_CheckListBoxOn = 1 const cAPEP_CheckListBoxOff = 0 //Caption const cAPEP_CaptionGreyOff = false const cAPEP_CaptionGreyOn = true const cAPEP_CaptionBoldOff = false const cAPEP_CaptionBoldOn = true const cAPEP_CaptionItalicOff = false const cAPEP_CaptionItalicOn = true const cAPEP_CaptionSmallOff = false const cAPEP_CaptionSmallOn = true const cAPEP_CaptionFullWidthOff = false const cAPEP_CaptionFullWidthOn = true const cAPEP_CaptionLineDefault = 1 // 2.3.68 Object Type Methods // There are no declarations for these methods as the values returned may change in future releases of AP. //.................................................................................................................................. // 2.4 APPlanObject (APO) //.................................................................................................................................. //Altitude (in degrees) const cAPO_MinAltitude = 0.0 const cAPO_MaxAltitude = 90.0 //Apparent Magnitude const cAPO_ApparentMagnitudeError = 99.0 //Object is below the horizon //Azimuth (in degrees) const cAPO_MinAzimuth = 0.0 const cAPO_MaxAzimuth = 360.0 //Dec (in degrees) const cAPO_MinDec = -90.0 const cAPO_MaxDec = 90.0 //Difficulty Index const cAPO_MinDifficultyIndex = 0.0 const cAPO_MaxDifficultyIndex = 100.0 //Extinction const cAPO_ExtinctionError = 99.0 //ForceHighlight const cAPO_ObjectHighlightOn = true const cAPO_ObjectHighlightOff = false //HourAngle const cAPO_MinHourAngle = -12.0 const cAPO_MaxHourAngle = 12.0 //IsHighlighted const cAPO_ObjectHighlightedOn = true const cAPO_ObjectHighlightedOff = false //IsVisible const cAPO_ObjectVisibleOn = true const cAPO_ObjectVisibleOff = false //Magnitude const cAPO_MinMagnitude = -30.0 const cAPO_MaxMagnitude = 30.0 const cAPO_DefMagnitude = 9.0 //Default object magnitude (I like this value - so there) const cAPO_MagnitudeError = 99.0 //or greater indicate a possible error condition //nObservations, nObs const cAPO_MinObservations = 1 const cAPO_MinGlobalObservations = 1 //PosAngle const cAPO_MinPosAngle = 0 const cAPO_MaxPosAngle = 360 //RA const cAPO_MinRA = 0.0 const cAPO_MaxRA = 23.99999 //Rise const cAPO_MinRise = 0.0 const cAPO_MaxRise = 23.9999 const cAPO_CircumpolarRise = -1 const cAPO_NeverRise = -2 //Selected const cAPO_ObjectSelectedOn = true //Object selected const cAPO_ObjectSelectedOff = false //Object not selected //Set const cAPO_MinSet = 0.0 const cAPO_MaxSet = 23.9999 const cAPO_CircumpolarSet = -1 const cAPO_NeverSet = -2 //Transit const cAPO_MinTransit = 0.0 const cAPO_MaxTransit = 23.9999 //NewObservation const cAPO_NoDateTime = 0.0 //.................................................................................................................................. // 2.5 APObservation (APOB) //.................................................................................................................................. //DateTime const cAPOB_NoDateTime = 0.0 //Same as NewObservation? (see 2.4) //IsAAVSO const cAPOB_IsAAVSOOn = true const cAPOB_IsAAVSOOff = false //.................................................................................................................................. // 2.6 APAAVSO (APA) //.................................................................................................................................. //MagDecPt const cAPA_MagDecPt1 = 1 const cAPA_MagDecPt2 = 2 const cAPA_MagDecPt3 = 3 //FainterThen const cAPA_FainterThanOn = true const cAPA_FainterThanOff = false //Uncertain const cAPA_UncertainOn = true const cAPA_UncertainOff = false //StepMagnitude const cAPA_StepMagnitudeOn = true const cAPA_StepMagnitudeOff = false //DoAirMass const cAPA_DoAirMassOn = true const cAPA_DoAirMassOff = false //ComputeAirMass const cAPA_ComputeAirMassOn = true const cAPA_ComputeAirMassOff = false //DoError const cAPA_DoErrorOn = true const cAPA_DoErrorOff = false //.................................................................................................................................. // 2.7 APCatalogObject (APCO) //.................................................................................................................................. //ID const cAPCO_MinID = 1 const cAPCO_NoID = "" //GetTypes //Need to play around with this to see if there is anything worth adding //.................................................................................................................................. // 2.8 APCatalog (APC) //.................................................................................................................................. //GetObject const cAPC_GetObjectMin = 1 const cAPC_GetObjectNone = nil //.................................................................................................................................. // 2.9 APTextFile (APTF) //.................................................................................................................................. //EOF const cAPTF_EOFYes = true //File is at EOF const cAPTF_EOFNo = false //File is not at EOF //ReadLine, ReadAll const cAPTF_ReadError = "" //Returned if ReadLine failed for some reason (e.g. File is not open) //.................................................................................................................................. // 2.10 APSearch (APS) //.................................................................................................................................. //See section 2.10.1 for an extenisive list of constants //MaxResults const cAPS_MaxResultsDef = 100 //Default maximum results //.................................................................................................................................. // 2.11 Canvas (APCV) //.................................................................................................................................. //Canvas Constructor const cAPCV_PageSetupOn = true //Call the page setup dialogue const cAPCV_PageSetupOff = false //Do not call the page setup dialogue //.................................................................................................................................. // 2.11.4 CanvasFOV (APCF) //.................................................................................................................................. //DrawFOV const cAPCF_BlackOnWhite = true //Do blank on white display const cAPCF_WhiteOnBlack = false //Do white on black display //FOVsize const cAPCF_FOVSizeMin = 0.1 const cAPCF_FOVSizeMax = 60.0 //FOVOption const cAPCF_FOVOptionOn = true const cAPCF_FOVOptionOff = false const cAPCF_FOVOptionAltAzRotation = "Alt/Az Rotation" const cAPCF_FOVOptionCustomReticles = "Custom Reticles" const cAPCF_FOVOptionConstellations = "Constellations" const cAPCF_FOVOptionExtMagRange = "Extended Magnitude Range" const cAPCF_FOVOptionFlipHorizontal = "Flip Horizontal" const cAPCF_FOVOptionFlipVertical = "Flip Vertical" //FOVCatalogue const cAPCF_NoCatalog = "" //Perform operation on all catalogues const cAPCF_CatalogOn = true //Select catalogue const cAPCF_CatalogOff = false //Deselect catalogue const cAPCF_CatalogLabelOn = true //Select catalogue labels const cAPCF_CatalogLabelOff = false //Deselect catalogue labels //FOVStarLimits const cAPCF_StarLimitMin = 0.0 //Minimum magnitude limit const cAPCF_StarLimitMax = 12.0 //Maximum magnitude limit const cAPCF_StarLimitExt = 30.0 //Extended magnitude limit //FOVApeture const cAPCF_FOVApetureOn = true //Draw the FOV circle and crosshair const cAPCF_FOVApetureOff = false //Do not draw the FOV circle and crosshair //SkyOption const cAPCF_OptionStateOn = true //Select the required option const cAPCF_OptionStateOff = false //Deselect the required option //Text constants for the options have not been added. //These options may change in future versions of AP. //I might just add these if I really feel the need!!! //DrawImage const cAPCF_TitleOn = true const cAPCF_TitleOff = false const cAPCF_InvertedOn = true const cAPCF_InvertedOff = false const cAPCF_GreyScaleOn = true const cAPCF_GreyScaleOff = false const cAPCF_ScaledOn = true const cAPCF_ScaledOff = false //IsUserImage const cAPCF_UserImage = true const cAPCF_DSSImage = false //.................................................................................................................................. // 2.11.5 Creating and drawing tables (APCT) //.................................................................................................................................. //DrawTable (These constants already exist, without the prefix of course) const cAPCT_GridNone = 0 const cAPCT_GridThin = 1 const cAPCT_GridThick = 2 //.................................................................................................................................. // 2.12 Table (APT) //.................................................................................................................................. //LoadFromText //const cAPT_DelimeterDef = chr(9) //REALbasic does not allow this - darn it!!! const cAPT_DelimiterDef = 9 //Default delimiter is Tab const cAPT_HasTitlesYes = true const cAPT_HasTitlesNo = false // 2.12.14 Formatting a table // This section details a bunch of formatting constants. // Not much point replicating them here. //.................................................................................................................................. // 2.13 Resources (APR) //.................................................................................................................................. const cAPR_SiteResourceMin = 1 const cAPR_SiteResourceNone = nil const cAPR_TelescopeResourceMin = 1 const cAPR_TelescopeResourceNone = nil const cAPR_EyepieceResourceMin = 1 const cAPR_EyepieceResourceNone = nil const cAPR_VisualAidResourceMin = 1 const cAPR_VisualAidResourceNone = nil //SiteResource, TelescopeResource, EyepieceResource //These can be used as general replacements for the equivalent declarations given below const cAPR_DefaultResourceYes = true const cAPR_DefaultResourceNo = false //.................................................................................................................................. // 2.13.2 SiteResource (APSR) //.................................................................................................................................. const cAPSR_DefaultSiteYes = true const cAPSR_DefaultSiteNo = false const cAPSR_USDSTYes = true const cAPSR_USDSTNo = false const cAPSR_EUDSTYes = true const cAPSR_EUDSTNo = false //.................................................................................................................................. // 2.13.3 TelescopeResource (APTR) //.................................................................................................................................. const cAPTR_DefaultTelescopeYes = true const cAPTR_DefaultTelescopeNo = false const cAPTR_IsTelescopeYes = true const cAPTR_IsTelescopeNo = false const cAPTR_IsBinocularYes = true const cAPTR_IsBinocularNo = false const cAPTR_FlipFinderHorizontalYes = true const cAPTR_FlipFinderHorizontalNo = false const cAPTR_FlipFinderVerticalYes = true const cAPTR_FlipFinderVerticalNo = false //.................................................................................................................................. // 2.13.4 EyepieceResource (APER) //.................................................................................................................................. const cAPER_DefaultEyepieceYes = true const cAPER_DefaultEyepieceNo = false //.................................................................................................................................. // 2.13.5 VisualAidResource (APVR) //.................................................................................................................................. const cAPVR_InvertsHorizontallyYes = true const cAPVR_InvertsHorizontallyNo = false const cAPVR_InvertsVerticallyYes = true const cAPVR_InvertsVerticallyNo = false //.................................................................................................................................. // 2.14 Serial port support (APSP) //.................................................................................................................................. const cAPSP_SerialPort1 = 1 const cAPSP_SerialPort2 = 2 const cAPSP_SerialPort3 = 3 const cAPSP_SerialPort4 = 4 //APSerialPort const cAPSP_BitRateDefault = 9600 const cAPSP_DataBitsDefault = 8 const cAPSP_StopBitsDefault = 1 const cAPSP_ParityEven = "Even" const cAPSP_ParityOdd = "Odd" const cAPSP_ParityNone = "None" const cAPSP_ParityDefault = "None" const cAPSP_FlowControlReset = "" const cAPSP_FlowControlXON = "XON" const cAPSP_FlowControlCTS = "CTS" const cAPSP_FlowControlDTS = "DTS" const cAPSP_FlowControlDefault = "" const cAPSP_ReceiveDefault = "" const cAPSP_ReceiveTimeoutDefault = 5 //================================================================================================================================== // Sub and functions //================================================================================================================================== //---------------------------------------------------------------------------------------------------------------------------------- // Constellation functions //---------------------------------------------------------------------------------------------------------------------------------- //.................................................................................................................................. // Name : ConstellationToInt // Purpose : Return the index of the matched Constellation abbreviation or full-name // Requires: Name - Constellation abbreviation or full-name to be matched // NameType - 1 = The Name given is a Constellation abbreviation // 2 = The Name given is a Constellation full-name // Returns : cMinConstellation...cMaxConstellation if a match of the appropriate type is found // cNoConstellation if no match is found // Notes : - Could be modified to check both constellation name types together, thus eliminating the need for the NameType // argument. There would be a small(ish) speed penalty, however, the array is only 88 elements so the penalty would // not be great. Mod would add and OR statement to the IF...THEN array element matching statement: // if (Name = Names(Index).NthField(cConstellationSep, cConstellationShortName)) or_ // (Name = Names(Index).NthField(cConstellationSep, cConstellationLongName)) then // This rather clumsy comparasion operation would be much simplified in ConstellationNames() and // ConstellationAbbreviations() existed. Then one or other of these could be assigned to Names and the 'if Name=' // comparasion would be much simpler. I haven't checked the RB manual to look for an array element matching function. //.................................................................................................................................. function ConstellationToInt (Name as string, NameType as integer) as integer const cIndexInc = 1 dim Found as boolean = false dim Index as integer = cConstellationMin dim Names(-1) as string Names() = Constellations() do until (Index = cConstellationMax+1) or Found if Name = Names(Index).NthField(cConstellationSep, NameType) then Found = true else Index = Index + cIndexInc end if loop if not(Found) then Index = cConstellationNone end if return Index end function //.................................................................................................................................. // Name : ConstellationAbbreviationToInt // Purpose : Return the index of the matched Constellation abbreviation // Requires: Name - Constellation abbreviation to be matched // Returns : cMinConstellation...cMaxConstellation if a match of the appropriate type is found // cNoConstellation if no match is found //.................................................................................................................................. function ConstellationAbbreviationToInt (Name as string) as integer return ConstellationToInt(Name, cConstellationShortName) end function //.................................................................................................................................. // Name : ConstellationNameToInt // Purpose : Return the index of the matched Constellation full-name // Requires: Name - Constellation full-name to be matched // Returns : cMinConstellation...cMaxConstellation if a match of the appropriate type is found // cNoConstellation if no match is found //.................................................................................................................................. function ConstellationNameToInt (Name as string) as integer return ConstellationToInt(Name, cConstellationLongName) end function //----- Library Script: lib_ASCII //################################################################################################################################## // Name : ASCII // Purpose : Standard library of ASCII constants // Requires: AP v1.5.1b3 or later // Author : Robin Lauryssen-Mitchell // Date : 05th September 2006 // Version : 1.0 // Status : Production // History : 0.1 - Initial 'in-house' release // 1.0 - First public release // Notes : This is a 'library' file. It is not intended to be run as a script, but to be 'linked' to other scripts. //################################################################################################################################## //================================================================================================================================== // Declarations //================================================================================================================================== //Non-printable const cNUL = 0 //Null const cSOH = 1 //Start of heading const cSTX = 2 //Start of text const cETX = 3 //End of text const cEOT = 4 //End of transmission const cENQ = 5 //Enquiry const cACK = 6 //Acknowledge const cBEL = 7 //Bell const cBS = 8 //Backspace const cHT = 9 //Horizontal tab const cLF = 10 //Line feed const cVT = 11 //Vertical tab const cFF = 12 //Form feed const cCR = 13 //Carriage return const cSO = 14 //Shift out const cSI = 15 //Shift in const cDLE = 16 //Data link escape const cDC1 = 17 //Device control 1 const cDC2 = 18 //Device control 2 const cDC3 = 19 //Device control 3 const cDC4 = 20 //Device control 4 const cNAK = 21 //Negative acknowledgement const cSYN = 22 //Synchronous idle const cETB = 23 //End of transmission block const cCAN = 24 //Cancel const cEM = 25 //End of medium const cSUB = 26 //Substitute const cESC = 27 //Escape const cFS = 28 //File separator const cGS = 29 //Group separator const cRS = 30 //Record separator const cUS = 31 //Unit separator const cDEL = 127 //Delete //Printable non-alphanumeric const cSpace = " " //32 const cBang = "!" //33 const cDblQuote = """" //34 const cHash = "#" //35 const cDollar = "$" //36 const cPercent = "%" //37 const cAmpersand = "&" //38 const cSngQuote = "'" //39 const cOpenBracket = "(" //40 const cCloseBracket = ")" //41 const cMult = "*" //42 const cPlus = "+" //43 const cComma = "," //44 const cMinus = "-" //45 const cPoint = "." //46 const cDivide = "/" //47 const cColon = ":" //58 const cSemicolon = ";" //59 const cLT = "<" //60 const cEqual = "=" //61 const cGT = ">" //62 const cQuery = "?" //63 const cAT = "@" //64 const cOpenSquare = "[" //91 const cSlash = "\" //92 const cCloseSquare = "]" //93 const cCaret = "^" //94 const cUnderscore = "_" //95 const cAccent = "`" //96 const cOpenBrace = "{" //123 const cBar = "|" //124 const cCloseBrace = "}" //125 const cTilde = "~" //126 ??? //Misc const cMinASCII = 0 //Lower character limit const cMaxASCII = 127 //Standard ASCII upper character limit const cExtASCII = 255 //Extended ASCII upper character limit //----- Library Script: lib_RLM_Declarations //################################################################################################################################## // Name : RPEHLM_Declarations // Purpose: Standard library of declarations to support RPEHLM authored scripts //################################################################################################################################## //================================================================================================================================== // Declarations //================================================================================================================================== //---------------------------------------------------------------------------------------------------------------------------------- // Constant declarations //---------------------------------------------------------------------------------------------------------------------------------- //Scratch Plan const cScratchPlan = "_RPEHLM.apd" //Temporary data holding plan const cRPEHLMPlanPrefix = "_RPEHLM" //ALL RPEHLM temporary plans will have this prefix (usually ignored by ChoosePlan) const cScratchCleanOn = true //Erase contents of temp plan const cScratchCleanOff = false //Do not erase contents of temp plan //Object copy operation flags (Might be AP_Declaration material) const cObjNoCopy = -1 //No list to be processed flag const cObjCopyAll = 0 //Process all plan objects const cObjCopyHighlighted = 1 //Process only highlighted plan objects const cObjCopySelected = 2 //Process only selected plan object //Misc. constants const cBaseIndex = 0 //Counting base, normally used with arrays const cNewline = 13 //Newline chr, normally used with dialogues (no longer needed really) //File constants const cEmptyFilePath = "" // const cWinPathSeparator = "\" //Windows file path separator //Message constants const cMsgUserCancelled = "INFO: User cancelled" const cMsgScriptComplete = "INFO: Script completed" const cMsgScriptException = "ERROR: An exception occurred!" const cMsgNoObjectSelected = "ERROR: No object selected" //Boolean constants const cTrueText = "True" const cFalseText = "False" //---------------------------------------------------------------------------------------------------------------------------------- //Script Save/Restore labels // Declared here because I may wish to use the same labels in other scripts // Combined with the SaveRestoreTag function this can be used to ensure global use of SaveRestore labels //---------------------------------------------------------------------------------------------------------------------------------- //SaveRestoreTag const cSaveRestoreTag = "RLM" //Used to enable common Save/Restore labels across multiple plans //Used by SimbadQuery const cSearchArea = "RLM_SearchArea" //Search area (object only, area around, wildcard, catalogue) const cSearchBib = "RLM_SearchBib" //Search bibliography const cSearchRadius = "RLM_SearchRadius" //Search radius const cSearchRadiusType = "RLM_SearchRadiusType" //Search radius type (deg, arcmin, arcsec) const cSearchType = "RLM_SearchType" //Search type (Selected Name, All Names, RA/Dec) //---------------------------------------------------------------------------------------------------------------------------------- // Dim declarations //---------------------------------------------------------------------------------------------------------------------------------- //General purpose dim CancelFlag as boolean = cAPGP_CancelledNo //Process cancel flag (normally user clicking a dialogue Cancel button) dim Index as integer = cBaseIndex //Loop counter (normally used to index arrays) //Plans dim MainPlanID as integer = cAPGP_NoPlan //ID of the main working plan dim MainPlanName as string = cEmptyFilePath //Name of the main working plan dim ScratchPlanID as integer = cAPGP_NoPlan //ID used for temporary data holding plan (usually _RPEHLM_Blank.apd) //----- Library Script: lib_RLM_Library //################################################################################################################################## // Name : RPEHLM_Library // Purpose: Standard library of routines to support RPEHLM authored scripts //################################################################################################################################## //================================================================================================================================== // Subs and Functions //================================================================================================================================== //---------------------------------------------------------------------------------------------------------------------------------- // Name: GetPlanIDbyName // Purpose: Return a PlanID associated with the submitted Plan name // Returns: PlanID or 0 if no matching name is found // Notes : PlanName should include the '.apd' suffix //---------------------------------------------------------------------------------------------------------------------------------- function GetPlanIDbyName (PlanName as string, byref PlanID as integer) as boolean dim PlanIndex as integer PlanID = cAPGP_NoPlan for PlanIndex = cAPGP_MinPlan to nPlans if GetPlanName(PlanIndex) = PlanName then PlanID = PlanIndex exit end if next return PlanID > cAPGP_NoPlan end function //---------------------------------------------------------------------------------------------------------------------------------- // Name: ChoosePlan // Purpose: Return a selected plan name, or an error condition // Detail: If more than one plan is loaded, allow the user to // select which plan to use. // If one plan is available, select that plan without user // intervention. // If no plans are available, return an error // Returns: Name - Name of the selected plan (empty if Flag=False) // Flag - -1 = user cancel // 0 = no plans loaded // 1..nPlans = selected plan ID // Notes: Hopefully nPlans() cannot return negative values!!! //---------------------------------------------------------------------------------------------------------------------------------- function ChoosePlan (byref Name as string, Sorted as boolean) as integer const cDialogueTitle = "Plan selection" const cSelectPlanLabel = "Select Plan:" dim Flag as integer = cAPGP_NoPlan //Returned status flag (-1=user cancel, 0=no plans loaded, 1..nPlans=selected plan ID) dim PlanIndex as integer //Plan list counter dim PlanNames(-1) as string //Plan list holding array select case nPlans() //Select from how many plans are available case cAPGP_NoPlan //No plans available so return error condition Flag = cAPGP_NoPlan Name = cEmptyFilePath case cAPGP_MinPlan //Only one plan available so return it's name if left(GetPlanName(cAPGP_MinPlan),len(cRPEHLMPlanPrefix)) = cRPEHLMPlanPrefix then //...unless it's ignored Flag = cAPGP_NoPlan //...in which case, set the NoPlan error conditions Name = cEmptyFilePath else Flag = cAPGP_MinPlan Name = GetPlanName(cAPGP_MinPlan) end if else //Build a popup list, choose one, make it current and return the name for PlanIndex = cAPGP_MinPlan to nPlans() //...build the list if left(GetPlanName(PlanIndex),len(cRPEHLMPlanPrefix)) <> cRPEHLMPlanPrefix then PlanNames.append GetPlanName(PlanIndex) end if next if Sorted then PlanNames.sort end if SetPopupParameter(cSelectPlanLabel, cBaseIndex, PlanNames) //Build the selection dialogue if EditParameters(cDialogueTitle) then //...choose a plan Flag = GetPlanNumber(PlanNames(GetPopupParameter(cSelectPlanLabel))) //...get the plan ID Name = GetPlanName(Flag) //...get the plan Name SelectPlan (Flag) //...make the selected plan current else //If the user Cancels the dialogue Flag = cAPEP_UserCancelled //... set up the error conditions Name = cEmptyFilePath end if end select return Flag end function //---------------------------------------------------------------------------------------------------------------------------------- // Name : LoadScratchPlan // Purpose: Remove all objects from a Plan // Returns: The scratch plan ID number // 0 - if the scratch plan is not loaded // Notes : Nothing happens if the scratch plan is already loaded //---------------------------------------------------------------------------------------------------------------------------------- function LoadScratchPlan (Clean as boolean) as integer dim CurrentPlanID as integer ScratchPlanID = GetPlanNumber(cScratchPlan) //See if the scratch plan is already loaded if ScratchPlanID = cAPGP_NoPlan then //If the scratch plan is not loaded then CurrentPlanID = CurrentPlanNumber // stash the current plan ID ScratchPlanID = OpenPlan(cScratchPlan) // load the scratch plan if (ScratchPlanID > cAPGP_NoPlan) and Clean then // If the scratch plan was loaded and Clean is set DeletePlanObjects(ScratchPlanID) // erase all objects from scratch plan end if SelectPlan(CurrentPlanID) // Restore the stashed selected plan else if Clean then DeletePlanObjects(ScratchPlanID) end if end if return ScratchPlanID //Return the scratch plan ID or error condition end function //---------------------------------------------------------------------------------------------------------------------------------- // Name : DumpScratchPlan // Purpose: Unload a scratch plan without saving it // Returns: The scratch plan ID number // 0 - if the scratch plan is not loaded //---------------------------------------------------------------------------------------------------------------------------------- function DumpScratchPlan (CloseFlag as boolean) as integer dim PlanID as integer PlanID=GetPlanNumber(cScratchPlan) //Make sure we are closing the scratch plan! if PlanID > cAPGP_NoPlan then //If the scratch plan is loaded then ... DeletePlanObjects(PlanID) //...Scratch Plan should always be empty ClosePlan(PlanID, CloseFlag) //...Close the scratch plan end if return PlanID //Um, not sure what I would ever do with this - but why not? end function //---------------------------------------------------------------------------------------------------------------------------------- // Name : DeletePlanObjects // Purpose: Remove all objects from a Plan //---------------------------------------------------------------------------------------------------------------------------------- sub DeletePlanObjects (PlanID as integer) dim ObjIndex as double dim CurrentPlan as integer CurrentPlan=CurrentPlanNumber SelectPlan(PlanID) //Need sanity check? if nObjects > cAPGP_NoObject then StartProgress("Emptying "+GetPlanName(PlanID), false, nObjects) for ObjIndex = nObjects downto cAPGP_MinObject Obj(ObjIndex).Delete if UpdateProgress(ObjIndex) then end if next StopProgress() end if SelectPlan(CurrentPlan) end sub //---------------------------------------------------------------------------------------------------------------------------------- // Name : StashObjectData // Purpose: Make a copy of the indexed object data //---------------------------------------------------------------------------------------------------------------------------------- //function StashObjectData (PlanID as integer, ObjectID as double) as ObjectFields // dim PObj as APPlanObject // dim ObjStash as ObjectFields // ObjStash = New ObjectFields // SelectPlan(PlanID) // if (ObjectID > 0) and (ObjectID <= nObjects) then // PObj=Obj(ObjectID) // ObjStash.Catalog = PObj.Catalog // ObjStash.Dec = PObj.Dec // ObjStash.ForceHighlight = PObj.ForceHighlight // ObjStash.ID = PObj.ID // ObjStash.Magnitude = PObj.Magnitude // ObjStash.Magnitude2 = PObj.Magnitude2 // ObjStash.Name = PObj.Name // ObjStash.Notes = PObj.Notes // ObjStash.Period = PObj.Period // ObjStash.PosAngle = PObj.PosAngle // ObjStash.RA = PObj.RA // ObjStash.Selected = PObj.Selected // ObjStash.Separation = PObj.Separation // ObjStash.Size = PObj.Size // ObjStash.Spectral = PObj.Spectral // ObjStash.Type = PObj.Type // ObjStash.User1 = PObj.User1 // ObjStash.User2 = PObj.User2 // ObjStash.User3 = PObj.User3 // ObjStash.User4 = PObj.User4 // else // print "ERROR: ObjectID out of range [" + str(ObjectID) + "]" // exit // end if // return ObjStash //end function //---------------------------------------------------------------------------------------------------------------------------------- // Name : CreateNewObject // Purpose: Create a new object in the required plan //---------------------------------------------------------------------------------------------------------------------------------- //function CreateNewObject(PlanID as integer, ObjStash as ObjectFields) as APPlanObject // dim PObj as APPlanObject // //Should check to see if PlanID is valid // SelectPlan(PlanID) // PObj = NewObject() // //Should have some error handling code here! (in case Object creation fails) // PObj.Catalog = ObjStash.Catalog // PObj.Dec = ObjStash.Dec // PObj.ForceHighlight = ObjStash.ForceHighlight // PObj.ID = ObjStash.ID // PObj.Magnitude = ObjStash.Magnitude // PObj.Magnitude2 = ObjStash.Magnitude2 // PObj.Name = ObjStash.Name // PObj.Notes = ObjStash.Notes // PObj.Period = ObjStash.Period // PObj.PosAngle = ObjStash.PosAngle // PObj.RA = ObjStash.RA // PObj.Selected = ObjStash.Selected // PObj.Separation = ObjStash.Separation // PObj.Size = ObjStash.Size // PObj.Spectral = ObjStash.Spectral // PObj.Type = ObjStash.Type // PObj.User1 = ObjStash.User1 // PObj.User2 = ObjStash.User2 // PObj.User3 = ObjStash.User3 // PObj.User4 = ObjStash.User4 // return PObj //end function //---------------------------------------------------------------------------------------------------------------------------------- // Name : CopyObjectToPlan // Purpose: Copy an Object from one Plan to another // Notes : The currently selected plan should remain the currently selected plan //---------------------------------------------------------------------------------------------------------------------------------- function CopyObjectToPlan (ObjectID as double, SourcePlanID as integer, TargetPlanID as integer) as double dim CurrentPlanID as integer //Currently selected plan ID dim ObjectData as APPlanObjectData //Temporary object stash type dim NewObjectID as double //New object ID (I think!) ObjectData = new APPlanObjectData //Create the temporary object stash CurrentPlanID = CurrentPlanNumber //Stash the current plan ID SelectPlan(SourcePlanID) //Change to the source plan ObjectData = Obj(ObjectID).Contents //Temporarily store the required object information SelectPlan(TargetPlanID) //Change to the target plan NewObject.Contents = ObjectData //Create the new object using the temporarily stored object information NewObjectID = nObjects //Theoretically object should be appended to the plan, therefore nObjects=new object id SelectPlan(CurrentPlanID) //Reselect the originally selected plan return NewObjectID //Hurl the new object ID back to the caller end function //---------------------------------------------------------------------------------------------------------------------------------- // Name : CopyPlanToPlan // Purpose: Copy the contents of one plan to another //---------------------------------------------------------------------------------------------------------------------------------- sub CopyPlanToPlan (SourcePlanID as integer, TargetPlanID as integer, CopyObjectFlag as integer) const cNoCopy = false const cYesCopy = true dim ObjectIndex as double dim CopyFlag as boolean = cNoCopy dim CurrentPlanID as integer dim ObjectData as APPlanObjectData CurrentPlanID = CurrentPlanNumber //Stash the orginal selected plan SelectPlan(SourcePlanID) StartProgress ("Copying from "+GetPlanName(SourcePlanID)+" to "+GetPlanName(TargetPlanID), true, nObjects) for ObjectIndex = cAPGP_MinObject to nObjects select case CopyObjectFlag case cObjCopyAll //All CopyFlag = cYesCopy case cObjCopyHighlighted //Highlighted CopyFlag = Obj(ObjectIndex).IsHighlighted case cObjCopySelected //Selected CopyFlag = Obj(ObjectIndex).Selected else CopyFlag = cNoCopy end select if CopyFlag then SelectPlan(SourcePlanID) ObjectData=Obj(ObjectIndex).Contents SelectPlan(TargetPlanID) NewObject.Contents=ObjectData SelectPlan(SourcePlanID) //MUST do this or FOR/NEXT fails end if if UpdateProgress(ObjectIndex) then exit end if next SelectPlan(CurrentPlanID) //Restore the orginal selected plan StopProgress() end sub //---------------------------------------------------------------------------------------------------------------------------------- // Name : BooleanToInteger // Purpose: Convert Boolean value to an Integer // Returns: 1 if Boolean value is true // 0 if Boolean value is false //---------------------------------------------------------------------------------------------------------------------------------- function BooleanToInteger (b as boolean) as integer if b then return 1 else return 0 end if end function //---------------------------------------------------------------------------------------------------------------------------------- // Name : IntegerToBoolean // Purpose: Convert Integer value to an Integer // Returns: True if Integer is 0 // False if Integer is not 0 //---------------------------------------------------------------------------------------------------------------------------------- function IntegerToBoolean (i as integer) as boolean if i=0 then return false else return true end if end function //---------------------------------------------------------------------------------------------------------------------------------- // Name : BooleanToString // Purpose: Convert Boolean value to a String // Returns: "True" if boolean is true // "False" if boolean is false //---------------------------------------------------------------------------------------------------------------------------------- function BooleanToString (b as boolean) as string if b then return cTrueText else return cFalseText end if end function //---------------------------------------------------------------------------------------------------------------------------------- // Name : StringToBoolean // Purpose: Convert String value to a Boolean // Returns: True if s="True" // False otherwise //---------------------------------------------------------------------------------------------------------------------------------- function StringToBoolean (s as string) as boolean if s = cTrueText then return true else return false end if end function //----- End of included Library Scripts //================================================================================================================================== // Declarations //================================================================================================================================== //---------------------------------------------------------------------------------------------------------------------------------- // Const declarations //---------------------------------------------------------------------------------------------------------------------------------- const cArrayMinIndex = 0 const cDelim = "," const cFlagOff = False const cFlagOn = True const cModifierKey = 42 // '\' const cNoSelectedObject = -1 //Simbad search parameters const cBibFromYear = 1983 //Minimum year for biblographic search (MaxYear is defined as a variable) const cBibFlagOff = "off" //Biblographic search is off const cBibFlagOn = "on" //Biblographic search is on const cRadiusDef = 10 //Default search radius (arcmins) const cRadiusUnitDef = 1 //Radius unit default (1=arcmin) const cSearchTypeDef = 0 //Application 'run' modes (see AppStateType) const cAppSimpleMode = 0 //Simple call to Simbad (no dialogue box) const cAppDialogMode = 1 //Display dialogue to allow more complex call to Simbad //How the selected object will be passed to Simbad (see SimbadType) const cLabelSelected = 0 //Pass Object.ID const cLabelAll = 1 //Pass Object.ID and Object.Names const cLabelRADec = 2 //Pass Object RA/Dec //Save & Restore labels const cBibFlag = "RLM_SimBibFlag" const cBibMaxYear = "RLM_SimBibMaxYear" const cBibMinYear = "RLM_SimBibMinYear" const cBleepFlag = "RLM_SimBleepFlag" const cDefaultFlag = "RLM_SimDefaults" const cModeFlag = "RLM_SimModeFlag" const cSearchFlag = "RLM_SimSearchFlag" const cSearchType = "RLM_SimSearchType" const cSearchRadius = "RLM_SimSearchRadius" const cSearchRadiusUnit = "RLM_SimSearchRadiusUnit" const cUseAllNames = "RLM_SimUseAllNames" //---------------------------------------------------------------------------------------------------------------------------------- // Class declarations //---------------------------------------------------------------------------------------------------------------------------------- class AppStateType dim RunMode as integer //Application execution mode dim DoIt as boolean //Do some processing flag (often returned from a sub or function) dim ExitFlag as boolean //Application exit state (T=exit, F=keep running) end class class SimbadType dim BibFlag as boolean // dim BibSearch as string //Biblographic search flag dim BibMinYear as integer //Minimum year for biblographic search dim BibMaxYear as integer //Maximum year for biblographic search dim BleepFlag as boolean //Do Bleep in Simple mode? dim DefaultFlag as boolean //Use Dialogue mode saved defaults for Simple mode? dim ModeFlag as boolean //True = force dialogue mode, False = allow use of modifier key dim NameFlag as boolean //Pass single name or all names dim NameList as string //List of object name/s or RA/Dec to pass dim Radius as integer //Search radius dim RadiusUnit as integer //Search radius type dim SearchFlag as boolean //Use dialogue values or Simbad defaults dim SearchType as integer //Type of search to perform (object only, object area or catalogue) end class //---------------------------------------------------------------------------------------------------------------------------------- // Var declarations //---------------------------------------------------------------------------------------------------------------------------------- dim AppState as AppStateType //Application state (supposed to be) dim SimbadData as SimbadType //Simbad enquiry data dim BibMaxYear as integer //Maximum year for biblographic searches (current year) //================================================================================================================================== // Subs and Functions //================================================================================================================================== //---------------------------------------------------------------------------------------------------------------------------------- // Name : Icon // Purpose: Initial conditions, set up data structurs etc. // Returns: Nothing //---------------------------------------------------------------------------------------------------------------------------------- sub Icon () dim KeyState as boolean //Get key-modifier state as early in the code as possible (helps avoid user confusion) KeyState = KeyDown(cModifierKey) //Initialise Type structures AppState = new AppStateType SimbadData = new SimbadType //Initialise with data stored from last use of dialogue mode (or defaults) SaveRestoreTag(cSaveRestoreTag) //Setup SaveRestoreTag to use RLM Library Tags SimbadData = RestoreSimbadData() //Initialise global variables BibMaxYear = YearOfDate(CurrentDate()) //Max year for bibliography search is the current year //Icon application state if KeyState or SimbadData.ModeFlag then AppState.RunMode = cAppDialogMode else AppState.RunMode = cAppSimpleMode end if AppState.DoIt = cFlagOff AppState.ExitFlag = cFlagOff //Don't exit the application end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : DoSimpleMode //Purpose : Call Simbad with object name and default values only //Requires: None //Returns : None //Notes : None //---------------------------------------------------------------------------------------------------------------------------------- sub DoSimpleMode() if RestoreBooleanValue(cDefaultFlag, cFlagOff) then //Set up Simbad parameters from stored parameters if RestoreBooleanValue(cBleepFlag, cFlagOff) then Bleep Bleep end if SimbadData = RestoreSimbadData() SimbadData.NameList = Obj(SelectedObject).ID else //Set up default Simbad parameters SimbadData.NameList = Obj(SelectedObject).ID SimbadData.SearchType = cSearchTypeDef SimbadData.Radius = cRadiusDef SimbadData.RadiusUnit = cRadiusUnitDef SimbadData.BibSearch = cBibFlagOff SimbadData.BibMinYear = cBibFromYear SimbadData.BibMaxYear = YearOfDate(CurrentDate()) end if AppState.DoIt = cFlagOn end sub //---------------------------------------------------------------------------------------------------------------------------------- // Name : DoDialogMode // Purpose: Choose an object list to process (must have a selected plan) // Returns: None //---------------------------------------------------------------------------------------------------------------------------------- sub DoDialogMode () const cNoName = "" //Dialog box labels const cAllNamesLabel = "Use all names?" const cBibFlagLabel = "Bibliography" const cBibFromLabel = "From" const cBibToLabel = "To" const cBleepLabel = "Bleep" const cDefaultLabel = "Set as Simple mode defaults" const cDialogTitle = "SimbadQuery Object: " const cForceDialogLabel = "Always use Dialogue Mode" const cMiscLabel = "Misc. settings:" const cNameLabel = "Name" const cObjectLabel = "Object Label" const cOtherLabel = "Other search parameters:" const cRadiusLabel = "Search radius" const cRadiusUnitLabel = "Radius type" const cRadiusUnits = "Degrees,ArcMinutes,ArcSeconds" const cSearchFlagLabel = "Search area" const cSearchTypeLabel = "Search type" //Dialogue box field defaults const cPopUpDef = 0 const cRadiusMax = 999 const cRadiusMin = 1 const cSearchTypes = "Object,Area,Catalogue" // dim NameText as string dim SelList(-1) as string NameText = Obj(SelectedObject).Name //Prepare the object selection list if NameText <> cNoName then SelList = split(NameText, cDelim) end if SelList.insert cArrayMinIndex, Obj(SelectedObject).ID //Add current ObjectID to selection list SelList.append SimbadRADec (Obj(SelectedObject).RA, Obj(SelectedObject).Dec) //Setup the dialogue SimbadData = RestoreSimbadData() SetPopupParameter (cAPEP_FieldAppendOff, cNameLabel, cPopUpDef, SelList) SetBooleanParameter(cAPEP_FieldAppendOff, cAllNamesLabel, RestoreBooleanValue(cUseAllNames, cFlagOff)) SetCaptionParameter(cAPEP_FieldAppendOff, cOtherLabel, 1, False, True, False, False, True) SetBooleanParameter(cAPEP_FieldAppendOff, cSearchFlagLabel, SimbadData.SearchFlag) SetPopupParameter (cAPEP_FieldAppendOff, cSearchTypeLabel, SimbadData.SearchType, split(cSearchTypes, cDelim)) SetIntegerParameter(cAPEP_FieldAppendOff, cRadiusLabel, SimbadData.Radius, cRadiusMin, cRadiusMax) SetPopupParameter (cAPEP_FieldAppendOff, cRadiusUnitLabel, SimbadData.RadiusUnit, split(cRadiusUnits, cDelim)) SetBooleanParameter(cAPEP_FieldAppendOff, cBibFlagLabel, SimbadData.BibFlag) SetIntegerParameter(cAPEP_FieldAppendOff, cBibFromLabel, SimbadData.BibMinYear, cBibFromYear, BibMaxYear) SetIntegerParameter(cAPEP_FieldAppendOff, cBibToLabel, SimbadData.BibMaxYear, cBibFromYear, BibMaxYear) SetCaptionParameter(cAPEP_FieldAppendOff, cMiscLabel, 1, False, True, False, False, True) SetBooleanParameter(cAPEP_FieldAppendOff, cForceDialogLabel, SimbadData.ModeFlag) SetBooleanParameter(cAPEP_FieldAppendOff, cDefaultLabel, RestoreBooleanValue(cDefaultFlag, cFlagOff)) SetBooleanParameter(cAPEP_FieldAppendOff, cBleepLabel, RestoreBooleanValue(cBleepFlag, cFlagOff)) //Setup dialog box dependencies ParameterDependency(cSearchTypeLabel, cSearchFlagLabel) ParameterDependency(cRadiusLabel, cSearchFlagLabel) ParameterDependency(cRadiusUnitLabel, cSearchFlagLabel) ParameterDependency(cBibFromLabel, cBibFlagLabel) ParameterDependency(cBibToLabel, cBibFlagLabel) //Show the Target List selection dialogue if EditParameters (cDialogTitle+Obj(SelectedObject).ID) then //Retrieve flag values from the dialogue box SimbadData.NameFlag = GetBooleanParameter(cAllNamesLabel) SimbadData.SearchFlag = GetBooleanParameter(cSearchFlagLabel) SimbadData.BibFlag = GetBooleanParameter(cBibFlagLabel) SimbadData.ModeFlag = GetBooleanParameter(cForceDialogLabel) SimbadData.DefaultFlag = GetBooleanParameter(cDefaultLabel) SimbadData.BleepFlag = GetBooleanParameter(cBleepLabel) //Find out which object name or names to use (Note: name could be RA/Dec) if SimbadData.NameFlag then SimbadData.NameList = Obj(SelectedObject).ID+cDelim+Obj(SelectedObject).Name else SimbadData.NameList = SelList(GetPopupParameter(cNameLabel)) end if //Get the search parameters requested if SimbadData.SearchFlag then //Use values from dialogue box SimbadData.SearchType = GetPopupParameter(cSearchTypeLabel) //+1 corrects for base diff SimbadData.Radius = GetIntegerParameter(cRadiusLabel) SimbadData.RadiusUnit = GetPopupParameter(cRadiusUnitLabel) else //or set up defaults SimbadData.SearchType = cSearchTypeDef SimbadData.Radius = cRadiusDef SimbadData.RadiusUnit = cRadiusUnitDef end if //Get bibliographic search parameters if SimbadData.BibFlag then SimbadData.BibSearch = cBibFlagOn else SimbadData.BibSearch = cBibFlagOff end if SimbadData.BibMaxYear = GetIntegerParameter(cBibToLabel) SimbadData.BibMinYear = GetIntegerParameter(cBibFromLabel) SaveSimbadData(SimbadData) //Save values for use as defaults next time around AppState.DoIt = cFlagOn else //User clicked Cancel button AppState.DoIt = cFlagOff AppState.ExitFlag = cFlagOn end if end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : SimbadRADec //Purpose : Take the object RA/Dec and convert into a form Simbad can use //Requires: Object RA and Dec as doubles //Returns : RA/Dec in Simbad format //Notes : Simbad format h+m+s.s+%2Bd+m+s.s //---------------------------------------------------------------------------------------------------------------------------------- function SimbadRADec (RA as double, Dec as double) as string const cRAFormat = "hms+" const cDecFormat = "dms+" const cExtended = True const cURLplus = "%2B" return FormatRA(RA, cExtended, cRAFormat) + cURLplus + FormatDec(Dec, cExtended, cDecFormat) end function //---------------------------------------------------------------------------------------------------------------------------------- //Name : DoURL //Purpose : Call Simbad search engine with required arguments (object, search area and bib) //Requires: SimbadData - contains all the URL argument data, either default or user-defined //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- sub DoURL (Simbad as SimbadType) const cURLRoot = "http://simbad.u-strasbg.fr/sim-id.pl?" //URL argument keys const cIdentKey = "&Ident=" //Object (or coorc) to search for const cBibFlagKey = "&b.code=" //Flag for biblographic search const cBibMinYearKey = "&Bibyear1=" //Minimum year keyword const cBibMaxYearKey = "&Bibyear2=" //Maximum year keyword const cProtocolKey = "protocol=" // const cRadiusKey = "&Radius=" //Search radius keyword const cRadiusUnitKey = "&Radius.unit=" // const cSearchAreaKey = "&NBIdent=" // const cSubmitKey = "&submit=" // //URL argument default values (not user definable - yet) const cProtocolDef = "html" const cRadiusUnits = "deg,arcmin,arcsec" const cSubmitDef = "submit+id" const cSearchArgs = "1,around,cat" //Search type argument to pass to Simbad (maps to cSearchTypes) OpenURL(cURLRoot+_ cProtocolKey + cProtocolDef+_ cIdentKey + Simbad.NameList+_ cSearchAreaKey + NthField(cSearchArgs, cDelim, Simbad.SearchType+1)+_ cRadiusKey + str(Simbad.Radius)+_ cRadiusUnitKey + NthField(cRadiusUnits, cDelim, Simbad.RadiusUnit+1)+_ cBibFlagKey + Simbad.BibSearch+_ cBibMinYearKey + str(Simbad.BibMinYear)+_ cBibMaxYearKey + str(Simbad.BibMaxYear)+_ cSubmitKey + cSubmitDef) end sub //---------------------------------------------------------------------------------------------------------------------------------- //Name : RestoreSimbadData //Purpose : Retrive saved values stored in the Plan file //Requires: - //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- function RestoreSimbadData () as SimbadType dim Simbad as SimbadType Simbad = new SimbadType Simbad.BibFlag = RestoreBooleanValue(cBibFlag, cFlagOff) if Simbad.BibFlag then Simbad.BibSearch = cBibFlagOn else Simbad.BibSearch = cBibFlagOff end if Simbad.BibMinYear = RestoreIntegerValue(cBibMinYear, cBibFromYear) Simbad.BibMaxYear = RestoreIntegerValue(cBibMaxYear, BibMaxYear) Simbad.BleepFlag = RestoreBooleanValue(cBleepFlag, cFlagOff) Simbad.DefaultFlag = RestoreBooleanValue(cDefaultFlag, cFlagOff) Simbad.ModeFlag = RestoreBooleanValue(cModeFlag, cFlagOff) Simbad.NameFlag = RestoreBooleanValue(cUseAllNames, cFlagOff) Simbad.Radius = RestoreIntegerValue(cSearchRadius, cRadiusDef) Simbad.RadiusUnit = RestoreIntegerValue(cSearchRadiusUnit, cRadiusUnitDef) Simbad.SearchFlag = RestoreBooleanValue(cSearchFlag, cFlagOff) Simbad.SearchType = RestoreIntegerValue(cSearchType, cSearchTypeDef) return Simbad end function //---------------------------------------------------------------------------------------------------------------------------------- //Name : SaveSimbadData //Purpose : Save values to the Plan file //Requires: - //Returns : - //Notes : - //---------------------------------------------------------------------------------------------------------------------------------- sub SaveSimbadData (Simbad as SimbadType) //Flags SaveBooleanValue(cUseAllNames, Simbad.NameFlag) SaveBooleanValue(cSearchFlag, Simbad.SearchFlag) SaveBooleanValue(cSearchBib, Simbad.BibFlag) //Search SaveIntegerValue(cSearchType, Simbad.SearchType) SaveIntegerValue(cSearchRadius, Simbad.Radius) SaveIntegerValue(cSearchRadiusUnit, Simbad.RadiusUnit) //Bibliography SaveBooleanValue(cBibFlag, SimbadData.BibFlag) SaveIntegerValue(cBibMaxYear, SimbadData.BibMaxYear) SaveIntegerValue(cBibMinYear, SimbadData.BibMinYear) //Misc. SaveBooleanValue(cModeFlag, SimbadData.ModeFlag) SaveBooleanValue(cDefaultFlag, SimbadData.DefaultFlag) SaveBooleanValue(cBleepFlag, SimbadData.BleepFlag) end sub //================================================================================================================================== // Main code //================================================================================================================================== Icon() if SelectedObject = cAPGP_NoSelectedObject then print cMsgNoObjectSelected exit else select case AppState.RunMode case cAppSimpleMode DoSimpleMode() case cAppDialogMode DoDialogMode() end select if AppState.DoIt then DoURL (SimbadData) end if end if