home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
caravan.zip
/
user.txt
< prev
next >
Wrap
Text File
|
2002-11-10
|
4KB
|
174 lines
Basics of caravan objects:
-------------------------
In this document the general concepts of caravan programming language is introduced.
Once this part is clear one has only to learn the various object types.
Most caravan objects are instantiated as :
<objecttype> <objectname>
examples:
user x
time t
Properties of caravan objects are accessed as:
<objectname>(<property>)
example:
user x
x(username);
Assignment
<objectname>(<property>)=<value>; //<value> is either a
//quoted string or a variable value
example:
user x
x(uid)="0";
x(uid)=form(uid);
x(domain)="admin"
Caravan object can have many properties and each property may have
one or more values; an example is "domain" property in "user" object
<objectname>(<property>)=<value1>
<objectname>(<property>)=<value2>
<objectname>(<property>)=<valueN>
Total number of values held by a property is given by:
<objectname>(<property>(00))
example :
user x;
x(domain(00));// gives the number of "domain" values of 'x'
Accessing a particular value when a property has more than one value:
<objectname>(<property>(0NN)) ;// N is a digit 0-9
example:
user x
x(domain(02));// access 2nd domain value
Iteration -- the loop statement
---------------------------------------------
Caravan has only one type of statement for doing iterations:
loop <loopname> (<max-loop-count>)
<statement>;
--
<statement>;
repeat <loopname> MAX
MAX is a numeric constant
max-loop-count is a constant or variable.
loop has a property called count access by <loopname>(count)
example: following will print 1 to 20;
loop myloop (20)
myloop(count);"<br>"
repeat myloop 100
example: following will print 1 to 10;
loop myloop (20)
myloop(count);"<br>"
repeat myloop 10
example: from "user.html"
loop dl (x(domain(00))); // max loop count is given by x(domain(00))
x(domain(dl(count)));"|";// access each domain-- dl(count) gives 01,02,03 etc
repeat dl 8
The conditional statements:
-----------------------------------------------------------------
if <condition>
<statement>;
else
<statement>;
endif
if <condition>
<statement>;
endif
if <condition1>
<statement>;
elseif <condition2>
<statement>;
elseif <conditionN>
<statement>;
endif
Examples of condition checking:
if <objectname> ;//checks if object is defined
if <objectname>(<property>) ;; checks if object and property are defined
if <objectname>(<property>) = <value> ;; if equal
if <objectname>(<property>) > <value> ;; if greater
if <objectname>(<property>) < <value> ;; if lesser
if <objectname>(<property>) >= <value> ;; if equal or greater
if <objectname>(<property>) <= <value> ;; if equal or lesser
//domain
// label and goto
--------------------
// goto <labelname>
// label <labelname>
// process termination : over statement
//----------------------------
// the statement to end the process is :
// over
// this will cause the data so far generated to be flushed to the browser;
// redirecting browser : redirect statement
//--------------------
// redirect "<url>"
// example:
// redirect "user.html"
// redirect "http://www.ibm.com/index.html"
// http request form
--------------------------
// When a request is posted to the server an object with name "form"
// is added to the object list of caravan.
// forms are generated in the following ways by the browser:
// 1.url encoded links like:
// <a href=user.html?test=1>test</a>
// 2. Explicit post statement in html like:
// <form>
// <input type=text name=test value="1">
// <input type=submit>
// </form>
// <form method=post action=user.html enctype=multpart/form-data>
// <input type=text name=test value="2">
// <input type=file name=testfile value=""> -- shows browse button
// <input type=submit>
// </form>
// in caravan one can check if a form has been posted by:
// if form
// if form(test)="1"
// "Ok test=1"
// endif
// endif
</caravan>