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

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