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