home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09962.iso / auto / cm95-10.zip / MCHAREN.OZ < prev    next >
Text File  |  1996-08-30  |  7KB  |  215 lines

  1. ;Gets Mona Charen's latest column, which is updated every Monday && Thursday.
  2.  
  3. ;****************************************************************************
  4. ; ClockMan95 Automation Assistant support file
  5. ; (c) 1995 Graphical Dynamics, Inc. The "Common helper functions" are placed
  6. ; in the public domain; otherwise permission is granted to use/modify this
  7. ; script file as long as it's not for resale.
  8. ;
  9. ; Written by: Jennifer Palonus
  10. ;
  11. ; Date    Who    Major changes
  12. ;-------  ---    -------------------------------------------------------------
  13. ;16aug95  jlp    Created.
  14. ;****************************************************************************
  15.     define $ServiceName        ; used by GoService
  16.     define #ServiceHasHdr    ; used by GoService
  17.     define $MenuItem        ; used by ChooseMenuItem & FindMenuItem
  18.     define $SubjectLine        ; used by CaptureMsg
  19.     define $Prompt            ; used by WaitForPrompt
  20.     define #OK                ; used everywhere. Routines return %TRUE or /%FALSE
  21.     onerror HandleErrors
  22.     timeout 90
  23.  
  24.  
  25. ;****************************************************************************
  26. ; Main processing section.
  27. ;****************************************************************************
  28.     set $ServiceName    "CIS:SYN-27"
  29.     set #ServiceHasHdr  %FALSE
  30.     set $Prompt         ^M^J "!"
  31.     gosub GoService
  32.  
  33.     set $MenuItem       "Mona Charen"
  34.     gosub FindMenuItem
  35.     if #OK = %FALSE fail
  36.  
  37.      set $MenuItem       "1"
  38.     gosub ChooseMenuItem
  39.  
  40.     set $SubjectLine    "Mona Charen"
  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.     set #OK %TRUE
  59.     sendln "GO " $ServiceName
  60.  
  61.     if #ServiceHasHdr = %FALSE return
  62.     set $Prompt ^M^J "MORE !"         
  63.     gosub WaitForPrompt
  64.     send %CR
  65.     return
  66.  
  67.     
  68. ;****************************************************************************
  69. ; ChooseMenuItem
  70. ;
  71. ; Selects an article (by item #) from a menu. Upon return, you're ready to
  72. ; CaptureMsg it.
  73. ;
  74. ; $MenuItem            The menu selection #.
  75. ; $SubjectLine        The generated mail message's subject line if different
  76. ;                    than the default.
  77. ; $Prompt            The prompt that ends the article. Usu. ^M^J "!".
  78. ;****************************************************************************
  79. ChooseMenuItem:
  80.     set #OK %TRUE
  81.     set $Prompt ^M^J "!"
  82.     gosub WaitForPrompt
  83.  
  84.     sendln $MenuItem
  85.     wait ^M^J            ; Skip echo of menu item #
  86.     return
  87.  
  88.  
  89. ;****************************************************************************
  90. ; FindMenuItem
  91. ;
  92. ; Selects the first item in a menu that contains the string in $MenuItem.
  93. ; Assumes the menu is being sent & ready to parse.
  94. ;
  95. ; This is for services that keep adding articles to the front of the menu,
  96. ; and the article we're looking for always has the same title. There can end
  97. ; up being 0, 1, or more items with the same name, in unpredictable positions
  98. ; in the menu. The 1st one we find (lowest item #) is the most recent one.
  99. ; (ex.: AP's "Today in History", or "<day>'s Most Active Stocks", etc.)
  100. ;
  101. ; Using this routine also protects you when the provider moves items around
  102. ; within a menu. (It doesn't protect against the provider changing menu
  103. ; item names or moving items to other menus.)
  104. ;
  105. ; Upon return, #OK is %TRUE or %FALSE depending on whether any items were
  106. ; found that contained $MenuItem. If %TRUE then $MenuItem is also set to the
  107. ; full menu item description & caller is ready to capture or parse the
  108. ; selected article/submenu.
  109. ;
  110. ; If $MenuItem is found in the preface to the menu, then I guess we could get
  111. ; into trouble!
  112. ;
  113. ; $MenuItem            The menu selection name (or partial name).
  114. ; $SubjectLine        The generated mail message's subject line if different
  115. ;                    than the default.
  116. ; $Prompt            The prompt that ends the article. Usu. ^M^J "!".
  117. ;****************************************************************************
  118. FindMenuItem:
  119.     define $FMILine
  120.     define $FMIItem
  121.     define $FMINum
  122.     define #FMIToken
  123.     define #FMIFound
  124.  
  125.     set #OK %TRUE
  126.     FMILoop:
  127.         add 1 "!"
  128.         add 2 ^M^J                ; Examine each line in turn...
  129.         mwait #FMIToken
  130.         
  131.         if #FMIToken = 2 goto FMICheckWholeLine
  132.  
  133.         ; ...else this is either a "!" or "MORE !" prompt, or a
  134.         ; stray "!" or "MORE !" inside a whole line...
  135.         set $FMILine %COMDATA
  136.         trim $FMILine
  137.  
  138.         ; If multipart menu, tell CIS to send next part...
  139.         if $FMILine = "MORE !" send %CR
  140.         if $FMILine = "MORE !" goto FMILoop
  141.  
  142.         ; If end of full menu & item wasn't found...
  143.         if $FMILine = "!" set #OK %FALSE
  144.         if $FMILine = "!" return
  145.  
  146.         FMICheckWholeLine:
  147.         set $FMILine %LCOMDATA
  148.         
  149.         ; Split off what should be item description & check it...
  150.         midstr $FMILine 4 255 $FMIItem
  151.         posnc #FMIFound $MenuItem $FMIItem
  152.     if #FMIFound = 0 goto FMILoop
  153.     
  154.     ; If we get here, we've found $MenuItem in a line...
  155.     midstr $FMILine 1 2 $FMINum
  156.     trim $FMINum        ; We ASSUME first nonblank chars are a real menu item #!
  157.  
  158.     ; Now that we have our item, skip the rest of the menu...
  159.     set $Prompt ^M^J "!"
  160.     gosub WaitForPrompt
  161.     sendln $FMINum
  162.     wait ^M^J                    ; Skip echo of menu item #
  163.     set $MenuItem $FMIItem        ; Return full menu item description
  164.     return
  165.  
  166.  
  167. ;****************************************************************************
  168. ; CaptureMsg
  169. ;
  170. ; Assuming CIS is about to send us the text that we want to place into a mail
  171. ; message, this routine captures the text 'till we get a <CR> & ! prompt.
  172. ;
  173. ; $SubjectLine        The custom subject line if different than the default.
  174. ; $Prompt            The prompt that ends the article. Usu. ^M^J "!".
  175. ;****************************************************************************
  176. CaptureMsg:
  177.     set #OK %TRUE
  178.     capture on CISMAIL.MSG
  179.     if $SubjectLine =  "" WMH
  180.     if $SubjectLine <> "" WMH $SubjectLine
  181.  
  182.     gosub WaitForPrompt
  183.     capture off
  184.  
  185.     set $SubjectLine ""
  186.     return
  187.  
  188.  
  189. ;****************************************************************************
  190. ; WaitForPrompt
  191. ;
  192. ; Wait till the end of a menu or opening text. This routine handles menus
  193. ; split up into multiple chunks, each of which end in "MORE !" prompts.
  194. ; If you DO want to wait for "MORE !", then set $Prompt to it.
  195. ;
  196. ; $Prompt            The prompt you're waiting for. Usu. ^M^J "!".
  197. ;****************************************************************************
  198. WaitForPrompt:
  199.     define #WFPToken
  200.     set #OK %TRUE
  201.     
  202.     add 1 $Prompt
  203.     add 2 ^M^J "MORE !"
  204.     mwait #WFPToken
  205.     if #WFPToken = 2 send %CR
  206.     if #WFPToken = 2 goto WaitForPrompt
  207.  
  208.     return
  209.  
  210.  
  211. ;****************************************************************************
  212. HandleErrors:
  213.     fail
  214.  
  215.