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 if () <> ;; if not equal The domain concept in caravan: --------------------------------- In caravan the users are grouped into various domains. Each user has a domain property which can have multiple values. You can restrict access to the the caravan generated pages by using the domain statement: domain ||....| example : domain admin;// access to only admin users. caravan automatically prompts for login , if the users does not have one of the domainnames. One can also check the domain of the user by using the conditional statements like: if domain<>"admin" "Sorry, access denied!" over endif 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 in html: 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 using code: if form if form(test)="1" "Ok test=1"; // outputs this to browser. endif endif