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