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

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