home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / caravan.zip / user.txt < prev    next >
Text File  |  2002-11-10  |  4KB  |  174 lines

  1.  
  2.  Basics of caravan objects:
  3.  -------------------------
  4.   In this document the general concepts of caravan programming language is introduced.
  5.   Once this part is clear one has only to learn the various object types.
  6.  
  7.   Most caravan objects are instantiated as :
  8.  
  9.   <objecttype> <objectname>
  10.  
  11.   examples:
  12.    user x
  13.    time t
  14.  
  15.   Properties of caravan objects are accessed as:
  16.  
  17.   <objectname>(<property>)
  18.  
  19.   example:
  20.    user x
  21.    x(username);
  22.  
  23.   Assignment
  24.   <objectname>(<property>)=<value>; //<value> is either a 
  25.                                     //quoted string or a variable value
  26.   example:
  27.    user x
  28.    x(uid)="0";
  29.    x(uid)=form(uid);
  30.    x(domain)="admin"
  31.  
  32.  
  33.   Caravan object can have many properties and each property may have 
  34.   one or more values; an example is "domain" property in "user" object
  35.  
  36.   <objectname>(<property>)=<value1>
  37.   <objectname>(<property>)=<value2>
  38.   <objectname>(<property>)=<valueN>
  39.  
  40.   Total number of values held by a property is  given by:
  41.  
  42.   <objectname>(<property>(00)) 
  43.  
  44.   example :
  45.    user x;
  46.    x(domain(00));// gives the number of "domain" values of 'x'
  47.  
  48.   Accessing a particular value when a property has more than one value:
  49.  
  50.   <objectname>(<property>(0NN)) ;// N is a digit 0-9
  51.  
  52.    example:
  53.     user x
  54.     x(domain(02));// access 2nd domain value
  55.  
  56.  Iteration  --  the loop statement 
  57.  ---------------------------------------------
  58.  Caravan has only one type of statement for doing iterations:
  59.  
  60.  loop <loopname> (<max-loop-count>)
  61.    <statement>;
  62.     --
  63.    <statement>;
  64.  repeat <loopname> MAX
  65.  
  66.  MAX is a numeric constant
  67.  max-loop-count is a constant or variable.
  68.  loop has a property called count access by <loopname>(count)
  69.  example: following will print 1 to 20;
  70.   loop myloop (20)
  71.     myloop(count);"<br>"
  72.   repeat myloop 100
  73.  
  74.  example: following will print 1 to 10;
  75.   loop myloop (20)
  76.    myloop(count);"<br>"
  77.   repeat myloop 10
  78.  
  79.  
  80.  example:  from "user.html"
  81.   loop dl (x(domain(00))); // max loop count is given by x(domain(00))
  82.    x(domain(dl(count)));"|";// access each domain-- dl(count) gives 01,02,03 etc
  83.   repeat dl 8
  84.  
  85.  
  86.  The conditional statements:
  87.  -----------------------------------------------------------------
  88.  
  89.  if <condition>
  90.    <statement>;
  91.  else 
  92.    <statement>;
  93.  endif
  94.  
  95.  if <condition>
  96.    <statement>;
  97.  endif
  98.  
  99.  if <condition1>
  100.    <statement>;
  101.  elseif <condition2>
  102.    <statement>;
  103.  elseif <conditionN>
  104.    <statement>;
  105.  endif
  106.  
  107.  
  108.  Examples of condition checking:
  109.   if <objectname> ;//checks if object is defined 
  110.  
  111.   if <objectname>(<property>) ;; checks if object and property are defined
  112.  
  113.   if <objectname>(<property>) = <value> ;; if equal
  114.  
  115.   if <objectname>(<property>) > <value> ;; if greater
  116.  
  117.   if <objectname>(<property>) < <value> ;; if lesser
  118.  
  119.   if <objectname>(<property>) >= <value> ;; if equal or greater
  120.  
  121.   if <objectname>(<property>) <= <value> ;; if equal or lesser
  122.  
  123. //domain
  124.  
  125. // label and goto
  126. --------------------
  127. // goto <labelname>
  128. // label <labelname> 
  129.  
  130. // process termination : over statement
  131. //----------------------------
  132. // the statement to end the process is :
  133. // over 
  134. // this will cause the data so far generated to be flushed to the browser;
  135.  
  136. // redirecting browser : redirect statement
  137. //--------------------
  138.  
  139.  
  140. // redirect "<url>"
  141. // example:
  142. // redirect "user.html" 
  143. // redirect "http://www.ibm.com/index.html" 
  144.  
  145. // http request form
  146. --------------------------
  147. // When a request is posted to the server an object with name "form" 
  148. // is added to the object list of caravan.
  149. // forms are generated in the following ways by the browser:
  150. // 1.url encoded links like:
  151.  
  152. // <a href=user.html?test=1>test</a>
  153.  
  154. // 2. Explicit post statement in html like:
  155.  
  156. // <form>
  157. // <input type=text name=test value="1">
  158. // <input type=submit>
  159. // </form>
  160.  
  161. // <form method=post action=user.html enctype=multpart/form-data>
  162. // <input type=text name=test value="2">
  163. // <input type=file name=testfile value=""> -- shows browse button 
  164. // <input type=submit>
  165. // </form>
  166.  
  167. // in caravan one can check if a form has been posted by:
  168. // if form
  169. //    if form(test)="1"
  170. //       "Ok test=1"
  171. //    endif
  172. // endif
  173. </caravan>
  174.