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

  1. ;Gets the latest stock quotes (15 min. delay during trading days). To specify
  2. ;the stocks you want to track, select "Services|Stock Quotes..." in OzCIS.
  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. ;16aug95  jlp    Created.
  15. ;****************************************************************************
  16.     define $QuotesFile        ; used by GetQuotes
  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 $QuotesFile %HOSTPATH "OZCIS.QTS"
  31.     set #OK fexists $QuotesFile
  32.     if #OK = %FALSE fail
  33.     fopen &1 $QuotesFile
  34.  
  35.     set $SubjectLine    "Latest Stock Quotes"
  36.     gosub StartCapture
  37.     capture off
  38.  
  39.     MainWhileTickers:
  40.     if #OK = %FALSE goto MainWend
  41.         set $ServiceName    "CIS:BASICQUOTES"
  42.         set #ServiceHasHdr  %FALSE
  43.         gosub GoService
  44.  
  45.         capture on CISMAIL.MSG
  46.         gosub GetQuotes
  47.         capture off
  48.     goto MainWhileTickers
  49.     MainWend:
  50.  
  51.     fclose &1
  52.     end
  53.  
  54.  
  55. ;****************************************************************************
  56. ; GetQuotes
  57. ;
  58. ; Gets up to 20 stock quotes from BASICQUOTES, using the ticker symbols
  59. ; listed in $QuotesFile. It assumes you've just sent a "GO CIS:BASICQUOTES".
  60. ;
  61. ; You must open the $QuotesFile as &1 before calling GetQuotes, and close it
  62. ; after GetQuotes returns #OK=%FALSE.
  63. ;
  64. ; Returns #OK=%TRUE if tickers were retrieved, else %FALSE if there was a
  65. ; problem or we're at EOF in the $QuotesFile.
  66. ;****************************************************************************
  67. GetQuotes:
  68.     define $GQTickers
  69.  
  70.     ; Extract up to 20 ticker symbols from the quotes file...
  71.     set $Prompt ^M^J "Issue: "
  72.     GQWhileNotEOF:
  73.     if #OK = %FALSE goto GQWend
  74.         gosub WaitForPrompt
  75.  
  76.         gosub BuildTickerList
  77.         if #OK = %TRUE sendln $GQTickers
  78.     goto GQWhileNotEOF
  79.     GQWend:
  80.  
  81.     return
  82.  
  83.  
  84. ;****************************************************************************
  85. ; BuildTickerList
  86. ;
  87. ; Builds up a comma-delimited list of ticker symbols as specified in OzCIS'
  88. ; Services|Stock Quotes... dialog & saved in the file OZCIS.QTS.
  89. ;
  90. ; Returns #OK=%TRUE if tickers were found in OZCIS.QTS, else %FALSE if there
  91. ; was a problem or no tickers in the file. Returns the list of tickers (if
  92. ; any) to $GQTickers.
  93. ;****************************************************************************
  94. BuildTickerList:
  95.     define #BTLNumTickers
  96.     define #BTLTemp
  97.     define $BTLThisTicker
  98.  
  99.     set #OK %TRUE
  100.     set #BTLNumTickers 0
  101.     set $GQTickers ""
  102.     
  103.     BTLWhileNotEOF:
  104.     if feof &1 goto BTLWend
  105.     if #BTLNumTickers = 20 goto BTLWend
  106.         freadln &1 $1
  107.         inc #BTLNumTickers
  108.  
  109.         ; Parse this line...
  110.         delstr $1 1 1
  111.         pos #BTLTemp ";" $1
  112.         dec #BTLTemp  ;End of ticker symbol or company name
  113.         midstr $1 1 #BTLTemp $BTLThisTicker
  114.         concat $GQTickers $BTLThisTicker
  115.         concat $GQTickers ","
  116.     goto BTLWhileNotEOF
  117.     BTLWend:
  118.  
  119.     ; Trim off trailing ","...
  120.     length #BTLTemp $GQTickers
  121.     if #BTLTemp > 0 delstr $GQTickers #BTLTemp 1
  122.     
  123.     if #BTLNumTickers <= 0 set #OK %FALSE
  124.     return
  125.  
  126.  
  127. ;****************************************************************************
  128. ; Common helper functions. (These are placed in the "public domain" by GDI.)
  129. ;****************************************************************************
  130. ; GoService
  131. ;
  132. ; Carries out a GO command & passes over the introductory text (if any).
  133. ; When this returns, you're ready to capture or parse the service's top menu.
  134. ;
  135. ; $ServiceName        The CIS service you want to GO to.
  136. ; #ServiceHasHdr    Does this service have an intro paragraph ending with a
  137. ;                    "MORE !" prompt?
  138. ;****************************************************************************
  139. GoService:
  140.     set #OK %TRUE
  141.     sendln "GO " $ServiceName
  142.  
  143.     if #ServiceHasHdr = %FALSE return
  144.     set $Prompt ^M^J "MORE !"         
  145.     gosub WaitForPrompt
  146.     send %CR
  147.     return
  148.  
  149.     
  150. ;****************************************************************************
  151. ; CaptureMsg
  152. ;
  153. ; Assuming CIS is about to send us the text that we want to place into a mail
  154. ; message, this routine captures the text 'till we get a <CR> & ! prompt.
  155. ;
  156. ; $SubjectLine        The custom subject line if different than the default.
  157. ; $Prompt            The prompt that ends the article. Usu. ^M^J "!".
  158. ;****************************************************************************
  159. CaptureMsg:
  160.     set #OK %TRUE
  161.     gosub StartCapture
  162.     gosub WaitForPrompt
  163.     capture off
  164.     return
  165.  
  166.  
  167. ;****************************************************************************
  168. ; StartCapture
  169. ;
  170. ; Assuming CIS is about to send us the text that we want to place into a mail
  171. ; message, this routine creates the mail message & starts capturing the text.
  172. ;
  173. ; $SubjectLine        The custom subject line if different than the default.
  174. ;****************************************************************************
  175. StartCapture:
  176.     set #OK %TRUE
  177.     capture on CISMAIL.MSG
  178.     if $SubjectLine =  "" WMH
  179.     if $SubjectLine <> "" WMH $SubjectLine
  180.     set $SubjectLine ""
  181.     return
  182.  
  183.  
  184. ;****************************************************************************
  185. ; WaitForPrompt
  186. ;
  187. ; Wait till the end of a menu or opening text. This routine handles menus
  188. ; split up into multiple chunks, each of which end in "MORE !" prompts.
  189. ; If you DO want to wait for "MORE !", then set $Prompt to it.
  190. ;
  191. ; $Prompt            The prompt you're waiting for. Usu. ^M^J "!".
  192. ;****************************************************************************
  193. WaitForPrompt:
  194.     define #WFPToken
  195.     set #OK %TRUE
  196.     
  197.     add 1 $Prompt
  198.     add 2 ^M^J "MORE !"
  199.     mwait #WFPToken
  200.     if #WFPToken = 2 send %CR
  201.     if #WFPToken = 2 goto WaitForPrompt
  202.  
  203.     return
  204.  
  205.  
  206. ;****************************************************************************
  207. HandleErrors:
  208.     fail
  209.  
  210.