home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 November / PCO1197.ISO / FilesBBS / WIN95 / CM95-10.EXE / APACTIVE.TS < prev    next >
Encoding:
Text File  |  1997-07-24  |  6.2 KB  |  231 lines

  1. ;***
  2. ; ClockMan95 Automation Assistant support file - TAPCIS script
  3. ; (c) 1995 Graphical Dynamics, Inc. The "Common helper functions" are placed
  4. ; in the public domain; otherwise permission is granted to use/modify this
  5. ; script file as long as it's not for resale.
  6. ;
  7. ; Written by: Jennifer Palonus
  8. ;
  9. ; Date    Who   Major changes
  10. ;-------  ---   -------------------------------------------------------------
  11. ;20nov95  jlp   Created.
  12. ;22nov95
  13. ;***
  14.  
  15. [*About this script*]
  16. Gets the latest closing Most Active Stocks summary from The Associated Press.
  17. This article is updated each weekday.
  18.  
  19. [*Script Setup*]
  20. Title=Get Most Active Stocks summary (latest)
  21.  
  22. ;***
  23. ; Main processing section.
  24. ;***
  25.  
  26. [*MenuItems*]
  27. text=Wall Street
  28. text=day's Most Active
  29.  
  30.  
  31. [Begin]
  32.         set @Timeout# 120
  33.         let ServiceName$        = "CIS:APONLINE"
  34.         let ServiceHasHdr       = @TRUE
  35.         let SubjectLine$        = "AP - Most Active Stocks"
  36.         let Prompt$                     = "^J!"
  37.         gosub "GoService"
  38.         if (OK = @FALSE) fail
  39.  
  40.         ForEach in MenuItems[] gosub "HandleMenu"
  41.         if (HMTFound = @FALSE) end
  42.  
  43.         gosub "CaptureMsg"
  44.         end
  45.  
  46.  
  47. ;***
  48. ; Common helper functions. (These are placed in the "public domain" by GDI.)
  49. ;***
  50. ; [GoService]
  51. ;
  52. ; Carries out a GO command & passes over the introductory text (if any).
  53. ; When this returns, you're ready to capture or parse the service's top menu.
  54. ;
  55. ; ServiceName$          The CIS service you want to GO to.
  56. ; ServiceHasHdr         Does this service have an intro paragraph ending with a
  57. ;                                       "MORE !" prompt?
  58. ;***
  59. [GoService]
  60.         let OK = @TRUE
  61.         send "GO " ServiceName$
  62.  
  63.         if (ServiceHasHdr = @FALSE) return
  64.         let Prompt$ = "^JMORE !"                 
  65.         gosub "WaitForPrompt"
  66.         send ""
  67.         return
  68.  
  69.         
  70. ;***
  71. ; [HandleMenu]
  72. ;
  73. ; Traverses the tree of menus until you're ready to capture a particular
  74. ; article. To call this function, declare an array section (ex.: [*Menus*])
  75. ; with menu item text and/or item numbers to look for, in either of these forms:
  76. ;     text=<text in menu item>
  77. ;     item=<menu item's number>
  78. ;     
  79. ; Then, call this function in a ForEach stmt: ForEach in Menus[] gosub "HandleMenu"
  80. ;
  81. ; SubjectLine$          The generated mail message's subject line.
  82. ; Prompt$                       The prompt that ends the article. Usu. "^J!".
  83. ;
  84. ; Upon return, OK is @TRUE or @FALSE depending on whether any matching items
  85. ; were found. If @TRUE then MenuItem$ is also set to the matching item #
  86. ; & caller is ready to capture or parse the selected article/submenu.
  87. ;***
  88. [HandleMenu]
  89.         let HMTFound = @FALSE
  90.         ;Dispatch to HMText or HMItem, depending on how to choose menu item (by
  91.         ;"Text" or menu "Item" #)...
  92.         goto "HM" @arrItem$
  93.         ;else bad menu cmd...
  94.                 Echo "Unrecognized menu item search type '" @arrItem$ "' in [HandleMenu]"
  95.                 fail
  96.  
  97. [HMText]
  98.         let HMSearchText$ = @arrValue$
  99.  
  100. ;1 or more menu sections. If >1, they're separated by "MORE !" prompts...
  101. [HMTLoop]
  102.         waitlist
  103.                 1 = "^JMORE !"
  104.                 2 = "^J!"
  105.         endlist
  106.         DoWaitMenu TheMenuLines[]
  107.         if (@waitMatch# = 0) goto "HMTNoMatchTimeout"
  108.  
  109.         ForEach in TheMenuLines[] gosub "HMTSelectItem"
  110.         if (HMTFound = @TRUE) return
  111.  
  112. [HMTNoMatch]
  113.         if (@waitMatch# = 1) goto "HMTNoMatchMore"
  114.         if (@waitMatch# = 2) goto "HMTNoMatchEOM"
  115.  
  116. [HMTNoMatchTimeout]
  117.         Echo "Timed out waiting for full menu"
  118.         fail
  119.  
  120. [HMTNoMatchMore]
  121.         send ""
  122.         goto "HMTLoop"
  123.  
  124. [HMTNoMatchEOM]
  125.         return
  126.  
  127.  
  128. [HMTSelectItem]
  129.         if (HMTFound = @TRUE) return
  130.  
  131.         if (@strstr (@arrValue$, HMSearchText$) = @FALSE) return
  132.         let HMTFound = @TRUE
  133.         Echo "We found '" HMSearchText$ "': #" @arrItem$ " = '" @arrValue$ "'!"
  134.         
  135.         send @arrItem$
  136.         return
  137.  
  138.  
  139. [HMItem]
  140.         let OK = @TRUE
  141.         let Prompt$ = ""
  142.         gosub "WaitForPrompt"
  143.  
  144.         send @arrValue$
  145.         return
  146.  
  147.         
  148. ;***
  149. ; [ChooseMenuItem]
  150. ;
  151. ; Selects an article from a menu by item #. Upon return, you're ready to
  152. ; CaptureMsg it.
  153. ;
  154. ; MenuItem$                     The menu selection #.
  155. ; SubjectLine$          The generated mail message's subject line if different
  156. ;                                       than the default.
  157. ; Prompt$                       The prompt that ends the article. Usu. "^J!".
  158. ;***
  159. [ChooseMenuItem]
  160.         let OK = @TRUE
  161.         let Prompt$ = "^J!"
  162.         gosub "WaitForPrompt"
  163.  
  164.         send MenuItem$
  165.         return
  166.  
  167.  
  168. ;***
  169. ; [CaptureMsg]
  170. ;
  171. ; Assuming CIS is about to send us the text that we want to place into a mail
  172. ; message, this routine captures the text 'till we get a <CR> & ! prompt.
  173. ;
  174. ; SubjectLine$          The custom subject line if different than the default.
  175. ; Prompt$                       The prompt that ends the article. Usu. "^J!".
  176. ;***
  177. [CaptureMsg]
  178.         if (@capName$ = "") let @capName$ = @pathMsg$ @svcName$ '.MSG'
  179.         let @hdrSub$ = SubjectLine$
  180.         Echo "Capturing article to " @capName$
  181.         CapHeader
  182.  
  183.         let OK = @TRUE
  184.  
  185.         let Prompt$ = "^J!"
  186.         gosub "WaitForPrompt"
  187.         CapClose
  188.  
  189.         let SubjectLine$ = ""
  190.         return
  191.  
  192.  
  193. ;***
  194. ; [WaitForPrompt]
  195. ;
  196. ; Wait till the end of a menu or opening text. This routine handles menus
  197. ; split up into multiple chunks, each of which end in "MORE !" prompts.
  198. ; If you DO want to wait for "MORE !", then set Prompt$ to it.
  199. ;
  200. ; Prompt$                       The prompt you're waiting for. Usu. "^J!".
  201. ;***
  202. [WaitForPrompt]
  203.         let OK = @TRUE
  204.         if (Prompt$ = "") let Prompt$ = "^J!"
  205.  
  206. [WFPLoop]
  207.         waitlist
  208.                 1 = Prompt$
  209.                 2 = "^JMORE !"
  210.                 3 = "^J!"
  211.         endlist
  212.         DoWaitMenu TheMenuLines[]
  213.         if (@waitMatch# = 1) return
  214.         if (@waitMatch# = 2) goto "WFPMore"
  215.         if (@waitMatch# = 3) return
  216.  
  217.         ; else...
  218.         let OK = @FALSE
  219.         Echo "...timed out waiting for a prompt"
  220.         return
  221.  
  222. [WFPMore]
  223.         Send ""
  224.         goto "WFPLoop"
  225.  
  226.  
  227. ;***
  228. [HandleErrors]
  229.         fail
  230.  
  231.