home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 September / PCWorld_2000-09_cd.bin / Software / TemaCD / deepsky / ds010100.exe / %MAINDIR% / Deepsky2000SlideShow.vbs < prev    next >
Encoding:
Text File  |  2000-07-21  |  6.0 KB  |  211 lines

  1. '    =======================
  2. '    DEEPSKY99SLIDESHOW.VBS 
  3. '    =======================
  4. '
  5. ' This ACP script does a guided tour of objects in the Deepsky 99 Observing Plan using voice control.
  6. ' This script will handle up to 500 objects.  Data from the Deepsky 99 Spreadsheet is loaded
  7. ' into the file Deepsky99SlideShow.sfl.  This script reads the file and uses ACP to position
  8. ' the scope onto the target object
  9. '
  10. ' Sample data from Deepsky99SlideShow.sfl looks like this :
  11. ' ---------------------------------------------------------
  12. '    !START
  13. '    21.805543 +23.456645 
  14. '    NGC 3435 
  15. '    located in the constellation of
  16. '    Orion
  17. '    has a magnitude of
  18. '    9.5.
  19. '    This object is of type
  20. '    Gx.
  21. '    !START
  22. '    21.805543 +23.456645 
  23. '    NGC 2345
  24. '    located in the constellation of
  25. '    Orion
  26. '    has a magnitude of
  27. '    10.5.
  28. '    This object is of type
  29. '    Oc.
  30. '
  31. ' Sample Text Spoken looks like this:
  32. ' -----------------------------------
  33. ' NGC 3435 located in the constellation of Orion has a magnitude of 9.5.  This object is of type Gx.
  34.  
  35. Dim bExit
  36. Dim sObject(500)
  37. Dim sRA(500)
  38. Dim sDec(500)
  39. Dim sDescription(500)
  40. Dim iObj
  41.  
  42. Dim dblRA
  43. Dim dblDec
  44. Dim strObject
  45. Dim strConText
  46. Dim strCon
  47. Dim strMagText
  48. Dim strMag
  49. Dim strTypeText
  50. Dim strType
  51.  
  52. Dim DesText
  53. Dim intCounter
  54.  
  55. '-----------------------------------------------------------------------------------------
  56. Sub main()
  57.   '
  58.   ' Add new spoken commands. The three parameters are
  59.   '   (1) The name of the event handler function
  60.   '   (2) The command as listed in the right-click menu and commands window
  61.   '   (3) The word to recognize in speech
  62.   '
  63.   Voice.Commands.Add "next_spoken", "Next", "next"
  64.   Voice.Commands.Add "previous_spoken", "Previous", "previous"
  65.   Voice.Commands.Add "alert", "Quit", "quit"
  66.   '
  67.   ' // Load the arrays of objects and their descriptions. The object names
  68.   '    are those that can be understood by Scope.SelectObject() and the
  69.   '    descriptions are what you want spoken.
  70.   Const ForReading = 1
  71.   Dim fs, a, retstring
  72.   Set fs = CreateObject("Scripting.FileSystemObject")
  73. Set a = FS.OpenTextFile("C:\data\Deepsky 98\Source98\Deepsky99SlideShow.sfl", ForReading, False)
  74.  
  75.   Do While a.AtEndOfStream <> True
  76.  
  77.     '// Read Start of Record
  78.          retstring = a.ReadLine
  79.     if retstring<>"!START" Then exit do
  80.  
  81.     '// Read RA and Dec
  82.          retstring = a.ReadLine
  83.     dblRA=left(retString,9)
  84.     dblDec=right(retString,10)
  85.  
  86.     '// Read Object Name
  87.          retstring = a.ReadLine
  88.     strObject=trim(retstring)
  89.  
  90.     '// Read Constellation Text
  91.          retstring = a.ReadLine
  92.     strContext=trim(retstring)
  93.  
  94.     '// Read Constellation
  95.          retstring = a.ReadLine
  96.     strCon=trim(retstring)
  97.  
  98.     '// Read Magnitude
  99.          retstring = a.ReadLine
  100.     strMag=retstring
  101.  
  102.     '// Read ObjectType
  103.          retstring = a.ReadLine
  104.     strType=trim(retstring)
  105.     
  106.     '// Concatenate Description String
  107.     DesText = strObject & " " & strConText & " " & strCon & " " & strMag
  108.     DesText = DesText & " " &  strType
  109.  
  110.     intCounter=intCounter+1     
  111.  
  112.     if intcounter>500 then exit do
  113.     
  114.     '// Add to the array
  115.     sObject(intCounter)=strObject
  116.     sRA(intCounter)=dblRA 
  117.     sDec(intCounter)=dblDec
  118.     sDescription(intCounter)=DesText
  119.   Loop
  120.   a.Close
  121.  
  122.   '// Exit Sub if nothing in array
  123.   voice.speak "Total Objects in the plan are" & intcounter
  124.  
  125.   if intCounter=0 then 
  126.         Voice.Speak "No objects were processed.  Please check to make sure the file called Deepsky99SlideShow.sfl contains valid information.  This file is where objects from Deepsky are stored for use by ACP."    
  127.     exit Sub
  128.   end if
  129.  
  130.   '
  131.   ' Tell user what to do on the console next, then enable speech input.
  132.   '
  133. 'Voice.Speak "Once you have centered and sinked on an alignment star, press F12 to tell Genie to listen, then say, next, to go to the next object in the plan, or, previous, to go to the previous object."
  134. 'Voice.Speak "Click the alert button or say, quit, to exit this plan script."
  135. voice.speak "To begin, say Next."
  136.   '
  137.   ' Initialize the object index. This starts at 1
  138.   '
  139.   iObj = 1
  140.   '
  141.   ' Enter a yield-loop to allow the system to call
  142.   ' our event handler(s) back when our command(s) are
  143.   ' spoken. Leave this loop when alert() sets the
  144.   ' bExit flag.
  145.   '
  146.   bExit = False            ' Use Alert to stop script
  147.   While Not bExit
  148.       Yield                ' Respond to events
  149.   Wend
  150. End Sub
  151.  
  152. '---------------------------------------------------------------------------------------------------
  153. ' //Agent will call this function when the word "next" is spoken. 
  154. Sub next_spoken(v,c)
  155.  
  156.   if iObj = intCounter then
  157.     Voice.Speak "That's the end of the list."
  158.   Else
  159.     GoToObject iObj
  160.     iObj = iObj + 1
  161.   End If
  162.  
  163. End Sub
  164.  
  165. '--------------------------------------------------------------------------------------------------
  166. ' // Agent will call this function when the word "previous" is spoken.
  167. Sub previous_spoken(v,c)
  168.  
  169.   if iObj = 1 then
  170.     Voice.Speak "That's the beginning of the list."
  171.   Else
  172.     iObj = iObj - 1
  173.     GoToObject iObj
  174.   End If
  175.  
  176. End Sub
  177.  
  178. '---------------------------------------------------------------------------------------------------
  179. '// This lets the alert() button or the "quit" commmand stop this script
  180. Sub alert(v,c)
  181.  
  182.   Voice.Listening = False                    ' Plug agent's ears
  183.   Voice.Speak "That's all."
  184.   bExit = True
  185.  
  186. End Sub
  187.  
  188. '----------------------------------------------------------------------------------------------------
  189. '// Slew the scope to the current RA and DEC
  190. Sub GoToObject(n)
  191.  
  192.   Voice.Speak "Going to " & sObject(n) & "."
  193.   Util.WaitForMilliseconds 4000                ' Allow time for speech
  194.  
  195.   Scope.ObjectRightAscension = sRA(n)
  196.   Scope.ObjectDeclination = sDec(n)
  197.   Scope.SlewToCurrentObject
  198.  
  199.   If not Scope.SlewToCurrentObject Then 
  200.       Voice.Speak "Sorry.  Object " & sObject(n) & " could not be located."
  201.       Exit Sub
  202.   End If
  203.   '
  204.   ' Right here, the "what's visible" feature will speak a description
  205.   ' of the object: "Scope is now pointed at xxxxx" if it is deep sky
  206.   '
  207.   Util.WaitForMilliseconds 1000
  208.   Voice.Speak "Target is Locked."
  209.   Voice.Speak sDescription(n)
  210. End Sub
  211.