Texis Web Script source code for:
/texis/site/demos/message.vs
Note: Click on links to view the documentation for HTML tags
which are special to the Vortex compiler.
<script language=vortex>
<uses demonav=demonav><!--simple look and feel module-->
<!--
Notes: This code example shows SQL INSERT DELETE ,and SELECT
Vortex is just HTML extended with programmatic tags and Texis SQL .
Vortex functions are defined with <a name=X> and closed by </a> .
Functions are called by using their name as a tag ie: <X>
The code is auto-compiled at the server into a Java-esque P-code.
A function is invoked by http://texis/script_name/function.html
SCHEMA: tsql "create table simpledb (When date,Who varchar(80),Comment varchar(512));"
-->
<entryfunc=init> <!-- init function for every invocation -->
<!-- --------------------------------------------------------------------- -->
<a name=init private>
<sum "%s" $SERVER_ROOT "/texis"><db = $ret> <!-- set the database -->
</a>
<!-- ----------------------------------------------------------------- -->
<a name=top>
<demolook title="Texis Simple Message Keeper Code Example">
</a>
<!-- ----------------------------------------------------------------- -->
<a name=bottom>
</demolook>
</a>
<!-- ----------------------------------------------------------------- -->
<a name=msgtable> <!-- Macro my table style -->
<center>
<table border=1 width=80%>
<tr><th>When</th><th>Who</th><th>Comment</th></tr>
</a>
<a name=msgrow>
<tr><td nowrap><fmt "%m/%d %H:%M" $When></td><td align=left>$Who</td><td align=left>$Comment</td></tr>
</a>
<a name=/msgtable>
</table>
</center>
</a>
<!-- ----------------------------------------------------------------- -->
<a name=dbexam PUBLIC>
<top>
This simple example allows you to create, search, and delete records from Texis database table.
<center>
<form method=post action=$url/dbexam.html>
Enter your text or query here:<br>
<textarea name=comment rows=2 cols=50>$comment</textarea>
<$actions = "Add new Record" "Search the records" "List all records" "Delete my messages">
<$values = "add" "search" "list" "del">
<br>
<if $onlyme eq "" >
<input type=checkbox name=onlyme value="1">
<$me = "">
<else>
<input type=checkbox name=onlyme value="1" checked>
<$me = $REMOTE_HOST>
</if> Just my records
<select name=action>
<options $values $action $actions>
</select>
<input type=submit value="go">
</center>
</form>
<switch $action>
<case "add">
<if $comment eq "">
<blink>I don't add empty records. Please enter something.</blink>
<else>
<sql "insert into simpledb values('now',$REMOTE_HOST,$comment);"/>
Your record was added.
</if>
<case "list">
<msgtable>
<sql null="" "select When, Who, Comment from simpledb where Who = $me order by When desc">
<msgrow>
</sql>
<nothing>
</msgtable>
<case "search">
<if $comment eq "">
<blink> Please enter a query.</blink>
<else>
<msgtable>
<apicp allinear yes>
<sql null="" "select When, Who, Comment from simpledb where Comment like $comment and Who = $me order by When desc;">
<msgrow>
</sql>
<nothing>
</msgtable>
</if>
<case "del">
Only your records will be deleted.
<center> <!-- Table format different, cant use the macro's -->
<table border=1 width=80%><tr><th> </th><th>When</th><th>Who</th><th>Comment</th></tr>
<sql "delete from simpledb where Who = $REMOTE_HOST">
<tr><td><b>deleted</b></td><td align=right>$When</td><td align=left>$Who</td><td align=left>$Comment</td></tr>
</sql>
<nothing>
</table>
</center>
</switch>
<bottom>
</a>
<!-- ----------------------------------------------------------------- -->
<a name=nothing>
<if $loop eq 0>
<tr><td colspan=4 align=center>There were no matching records</td></tr>
</if>
</a>
<!-- ----------------------------------------------------------------- -->
<a name=main PUBLIC> <!-- main is the default entry point -->
<dbexam>
</a>
</script>
The Source Viewer is also a Code Example.
Click Here to see its source.
Copyright © 1992-1999 Thunderstone Software