((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 () ; -- ; repeat MAX MAX is a numeric constant max-loop-count is a constant or variable. loop has a property called count access by (count) example: following will print 1 to 20; loop myloop (20) myloop(count);"
" repeat myloop 100 example: following will print 1 to 10; loop myloop (20) myloop(count);"
" 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 ; else ; endif if ; endif if ; elseif ; elseif ; endif Examples of condition checking: if ;//checks if object is defined if () ;; checks if object and property are defined if () = ;; if equal if () > ;; if greater if () < ;; if lesser if () >= ;; if equal or greater if () <= ;; if equal or lesser //domain // label and goto -------------------- // goto // label // 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 "" // 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: // test // 2. Explicit post statement in html like: //
// // //
//
// // -- shows browse button // //
// in caravan one can check if a form has been posted by: // if form // if form(test)="1" // "Ok test=1" // endif // endif HTTP/1.1 200 OK Server: CARAVAN Date: Sun, 10 Nov 2002 07:08:51 GMT Connection: Keep-Alive x-From: adint content-type: text/plain Last-Modified: Sun, 10 Nov 2002 07:08:51 GMT Cache-control: no-cache pragma: no-cache Content-length: 4249 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 : examples: user x time t Properties of caravan objects are accessed as: () example: user x x(username); Assignment ()=; // 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 ()= ()= ()= Total number of values held by a property is given by: ((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: ((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 () ; -- ; repeat MAX MAX is a numeric constant max-loop-count is a constant or variable. loop has a property called count access by (count) example: following will print 1 to 20; loop myloop (20) myloop(count);"
" repeat myloop 100 example: following will print 1 to 10; loop myloop (20) myloop(count);"
" 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 ; else ; endif if ; endif if ; elseif ; elseif ; endif Examples of condition checking: if ;//checks if object is defined if () ;; checks if object and property are defined if () = ;; if equal if () > ;; if greater if () < ;; if lesser if () >= ;; if equal or greater if () <= ;; if equal or lesser //domain // label and goto -------------------- // goto // label // 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 "" // 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: // test // 2. Explicit post statement in html like: //
// // //
//
// // -- shows browse button // //
// in caravan one can check if a form has been posted by: // if form // if form(test)="1" // "Ok test=1" // endif // endif