Texis Web Script source code for: /texis/site/demos/newsquote.vs
Note: Click on links to view the documentation for HTML tags which are special to the Vortex compiler.
<script language=vortex>

<export $id>
<export $tick url userok>
<uses demonav=demonav><!--simple look and feel module-->
<entryfunc=init>
<!-- What to do if the quoteserver is down ------------------------------------>
<timeout=10>
The Quote Server is temporarily unavailable.<br>
Please try again later.

</timeout>

<a name=retired>
   <p style="background-color: yellow; border: medium double black; padding: 1em 1em;">
      This code example is retired.
      See the <a target="_top" href="/texis/site/demos/dnewsquote">new realtime news code example</a>
      that uses RSS feeds instead of USENET as the source of articles.
   </p>
</a>

<a name=init private>
  <if '' eq $SERVER_ROOT><$SERVER_ROOT=/usr2/pub/httpd></if>
  <sum "%s" $SERVER_ROOT "/texis"><db = $ret>  <!-- set the database -->
  <sum "%s" $SERVER_ROOT "/graphing/stockgraph"><$StockGraph = $ret>
</a>

<!--Macro for header and footer ---------------------------------------->

<a name=hdr>
<if $tick eq "">
   <$tick=msft>
</if>
<demolook title="Texis Quotes and News Code Example">
   <retired></demolook><exit>
</a>


<a name=ftr>
<h6 align=right>Copyright © 2007 <a href=/>Thunderstone</a> - EPI, Inc. </h6>
</demolook>
</a>

<!---------------------------------------------------------------------------->

<a name=red><span style="color: red"></a>
<a name=/red></span></a>

<!--Display the graph --------------------------------------------------------->

<!-- stockgraph expects
Title text
junk
Label(the date),High,Low,Close,Volume
--- msn format as of 7-21-01
"US and Canadian historical stock prices and US indices prices provided by CSI,
Inc."
"US historical mutual fund and industry prices provided by Media General Financi
al Services."
"International stock prices and International indices prices provided by Interac
tive Data Corporation."
Intl Business Machines (IBM)
Weekly prices
DATE,OPEN,HIGH,LOW,CLOSE,VOLUME
7/20/2001,103.4,109.38,103.03,105.7,48299000
-->
<a name=gethistdata>
<local page>
  <strfmt "http://data.moneycentral.msn.com/scripts/chrtsrv.dll?Symbol=%U&FileDownload=&C1=0&C2=1&C3=&C4=1&C5=1&C6=&C7=1&C8=&C9=1&CA=&CB=&CC=&CD=&CE=&CF=&D0=&D1=&D2=&D3=&D4=&D5=&D6=&D7=&D9=" $tick>
  <fetch urls=$ret />
  <$page=$ret>
  <rex "\x0a\RDATE," $page />
  <if '' eq $ret><!-- 4-4-2007 - get from html page -->
     <strfmt "http://moneycentral.msn.com/investor/charts/chartdl.aspx?PT=7&D5=1&D2=0&compsyms=&D4=1&MA0=0&MA1=0&D7=&D6=&C5=1&C5D=1&C6=&C7=1&C7D=1&C8=&showtablbt=Price+history+table&symbol=%U&nocookie=1" $tick>
     <fetch urls=$ret />
     <$page=$ret>
     <rex '>><title>\P=! - +' $page />
     <capture>
     $ret ($tick)
     Date,High,Low,Close,Volume
     <rex '\L<table id="htmChrtLst"\L=!<tbody>+<tbody>\P=!</tbody></table>+\F</tbody></table>' $page />
     <sandr "," "" $ret>
     <sandr "<tr><td>" "" $ret>
     <sandr "</td></tr>" "\x0a" $ret>
     <sandr "</td><td>" "," $ret>
     <sandr ",=[^,]*,=[^,]*,=[^,]*>>\x0a" "\3\4\5\6\7" $ret><!-- rm open col -->
     $ret<!--nop-->
     </capture>
  <else>
     <sandr ".*[^\x0a]*\x0d\x0aWeekly prices\x0d\x0a=>>DATE,OPEN,HIGH,LOW,CLOSE,VOLUME=.+" "\2\x0d\x0a\4\5" $page>
     <sandr ">>\x0a=[^,]*,=[^,]*," "\1\2\3" $ret>
  </if>
</a>

<a name=graphit PUBLIC>
  <gethistdata>
  <exec BIN $StockGraph>
    <send $ret>
  </exec>
  $ret
</a>

<!--Display article full text-------------------------------------------------->

<a name=article PUBLIC>
<hdr>
<sql max=1 "select id,Date,Subject,Category,Keywords,Body from nevents where id=$id">
   <b><red>Date:</red></b> <fmt "%m/%d %H:%M EST" $Date><br>
   <b><red>Category:</red></b> $Category <br>
   <if $Keywords neq ""><b><red>Keywords:</red></b> $Keywords<br></if>
   <sandr "\n=\space+" "<p>\x0a\x0a" $Body>                <!-- do paragraph markup -->
   <sandr "!http://=>>www\.=" "http://www\." $ret> <!-- look for URL's -->
   <sandr "http://" " <a href=http://" $ret>
   <sandr "http:=[\alnum\-/\.]\P+." "><b>HERE</b></a> " $ret> <!-- Hyperlink -->
   <h3 align=center>$Subject</h3>
   <center><table boder=0><td><td><pre><send $ret></pre></td></tr></table></center>
</sql>
<ftr>
</a>

<!--Get the quote-------------------------------------------------------------->

<a name=symparse>
<timport "csv {
          keepfirst
          field   Exchange     varchar   1
          field   Last         double    4
          field   High         double    7
          field   Low          double    8
          field   Cumvol       long      9
          field   Change       double   11
          field   Open         double   12
          field   Yclose       double   14
         " $parsethis />
</a>

<a name=quote PUBLIC>
<!--
<exec nobr /usr/local/bin/gettick -h199.221.68.77 sym $tick></exec>
-->
<!-- wtf - get quotes from somewhere
<urlcp timeout 5>
<strfmt "%s/%U" "http://208.51.1.102:10000" $tick>
<fetch $ret>
<$parsethis=$ret>
<symparse>
-->
<table border=1>
<tr>
   <td valign=top>
<!-- wtf - get quotes from somewhere?
      <table>
         <tr><td align=left>Last</td><td align=right><fmt "%F" $Last></td></tr>
         <tr><td colspan=2><hr></td></tr>
         <tr><td align=left>Change</td><td align=right><if $Change lt 0.0><red><fmt "%F" $Change></red><else><fmt "%F" $Change></if></td></tr>
         <tr><td colspan=2><hr></td></tr>
         <tr><td align=left>High</td><td align=right><fmt "%F" $High></td></tr>
         <tr><td colspan=2><hr></td></tr>
         <tr><td align=left>Low</td><td align=right><fmt "%F" $Low></td></tr>
         <tr><td colspan=2><hr></td></tr>
         <tr><td align=left>Volume</td><td align=right><fmt "%kd" $Cumvol></td></tr>
         <tr><td colspan=2><hr></td></tr>
         <tr><td align=left>Previous Close</td><td align=right><fmt "%F" $Yclose></td></tr>
         <tr><td colspan=2><hr></td></tr>
         <tr><td colspan=2 align=center><b>Quote delay >15 minutes</b></td></tr>
      </table>
-->
   </td>
   <td valign=middle align=center><!-- width=450 height=300 -->
     <img  src=$url/graphit.gif></center>
   </td>
</tr>
</table>
</a>

<!--Display a headline row----------------------------------------------------->

<a name=headline>
<small><fmt "%m/%d %H:%M EST" $Date></small> <a href="$url/article.html"><b>$Subject</b></a><br>
</a>

<!--Search the news database--------------------------------------------------->

<a name=newsquery>
<nobr>
<sum "==%s" $tick>
<$t=$ret>
<!-- base href="http://index.thunderstone.com/" -->
<sql max=50 "select id,Date,Subject,Category,Keywords 
                    from nevents 
                    where Keywords like $t 
                    order by Date desc">
    <headline>
</sql>
<if $loop eq 0>
    <h5>There are no articles containing: $tick</h5>
</if>
<if $loop lt 5>
    <h5>Trying Keyword Search for: $Company</h5>
    <sql max=25 "select id,Subject,Category,Keywords 
                 from nevents 
                 where Category\Keywords\Subject\Body like3 $Company
                 order by Date desc">
                    
       <headline>
    </sql>
</if>
<if $loop eq 0>
<h5> No articles match "$Company" in the last 30 Days</h5>
</if>
</nobr>
</a>

<!--Look up the symbol--------------------------------------------------------->

<a name=symlu>
<$exchs = amex nyse otc>
<$Symbol = >
<upper $tick>
<sql max=1 "select Symbol,Company,Exchange from tick where  Symbol = $ret order by Company"/>

<if $Symbol eq "">
 <sql max=100 "select Symbol,Company,Exchange from tick where Company likep $tick order by Company"/>
</if>

<if $#Symbol eq 1>
  <$tick=$Symbol>
  <$dosearch=1>
<elseif $#Symbol gt 1>
     <table>
     <loop $Symbol $Company $Exchange>
     <rex $exchs $Exchange />
     <if $ret neq "">
        <tr><td align=left>$Company</td><td><a href=$url?tick=$Symbol>$Symbol</a></td></tr>
     <else>
        <tr><td align=left>$Company</td><td>$Symbol</td><td><small> -- No Quotes or News available -- </small></td></tr>
     </if>
     </loop>
     </table>
 <else>
Sorry, the company you entered is unknown by this database
<exit>
</if>
</a>

<!--Spew the query form-------------------------------------------------------->

<a name=qform>
<form method=post action="$url/">
Enter a ticker symbol or company name: <input name=tick size=20 value="$tick"><input type=submit value="Search">
</form>
</a>

<!--The main entry point for this script--------------------------------------->

<a name=main>
<hdr>
     <qform>
<symlu> 
<if $dosearch eq 1>
   <b>$Company ($tick) <fmt "%t" now></b><br>
   <quote>
   <newsquery>
<p style="font-size: 7pt"><sup>*</sup> Thunderstone - EPI, Inc. makes no guarantee about the accuracy of any stock prices presented in this code example.</p>
</if>
<ftr>
</a>

<!--That's all folks! --------------------------------------------------------->
</script>

Back to the Code Example List

The Source Viewer is also a Code Example.
Click Here to see its source.
Copyright © 1992-1999 Thunderstone Software
Copyright © 2024 Thunderstone Software LLC. All rights reserved.