Subversion Repositories wimsdev

Rev

Rev 7809 | Rev 17238 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. !read tabletheme
  2. <h4>Definition and substitution of variables</h4>
  3.  
  4. Wims variables have only one type: they are all string variables. Numerical
  5. evaluation can be done on variables via the variable command
  6. $(ref1)cmdlist_eval_&+cmd_choose=all$(ref2)cmdlist_eval_">!eval</a>.
  7. <p>
  8. A variable may be defined or modified in a variable processing file, or by
  9. the commands
  10. $(ref1)cmdlist_let_&+cmd_choose=all$(ref2)cmdlist_let_">!let</a> and
  11. $(ref1)cmdlist_default_&+cmd_choose=all$(ref2)cmdlist_default_">!default</a>.
  12. </p><p>
  13. Variable names can contain any alphanumeric character, as well as the
  14. underscore character $(emph)_$emphend. There is a limit to the length of
  15. variable names, and a limit to the length of values. (Limits depending on
  16. server configuration.)
  17. </p><p>
  18. Variable substitution can be done anywhere in a variable processing file or
  19. a phtml file (even in the name field of a variable definition
  20. line). A word preceeded by the character $emph$$$emphend
  21. is considered to be a variable name, and will be replaced by its value when
  22. the line containing it is processed.
  23. </p><p>
  24. Special rules of variable substitution:
  25. </p>
  26. <ul>
  27. <li>If the character $emph$$$emphend is followed by a space, it will be
  28.  discarded.
  29. </li><li>The string $emph$$$$$emphend is replaced by a single $emph$$$emphend.
  30. </li><li>If the character $emph$$$emphend is followed by the left parenthesis
  31.  $emph($emphend, the matching $emph)$emphend will be located, the content
  32.  of the pair of parentheses substituted. The result of the substitution
  33.  will then be used as the name of variable, and finally the whole thing
  34.  will be replaced by the value of the last variable. This allows nested
  35.  substitutions, as well as substitution of a variable which is followed
  36.  by an alphanumeric character.
  37.  <br/>Example: if the variable $(emph)i$emphend has value $(emph)3$emphend
  38.  and the variable $(emph)alpha3beta$emphend has value $(emph)pi$emphend,
  39.  the string<pre>3*$$(alpha$$(i)beta)*x</pre>
  40.  will become<pre>3*pi*x</pre>
  41.  after substitution.
  42.  <p>
  43.  Array addressing: if the variable $(emph)i$emphend contains a
  44.  comma-separated list $(emph)a,b,c,d,e$emphend, then the string
  45.  <span class="tt">$$(i[3])</span> gives <span class="tt">c</span> after substitution, and
  46.  <span class="tt">$$(i[2 to 4])</span> gives <span class="tt">b,c,d</span>, etc.
  47.  </p><p>
  48.  Two-dimensional array addressing is also available: if</p>
  49.  <pre>$$M=x,y,z;a,b,c</pre>
  50.  (a 2x3 matrix), then
  51.  <pre>$$(M[1;3,2])=z,y</pre>
  52.  </li><li>If the character $emph$$$emphend is followed by the left bracket
  53.  $emph[$emphend, the matching $emph]$emphend will be located, the content
  54.  of the pair of brackets substituted then evaluated to a real number value whose
  55.  precision depends on the value of $emph print_precision$emphend.
  56.  This value will replace the whole thing
  57.  together with the leading $emph$$$emphend. <br/>
  58.  It can be used for array subscripts.
  59.  <br/>Example: if the variable $(emph)i$emphend has value $(emph)3$emphend
  60.  and the variables <br/>
  61.  $(emph)a1$emphend has value $(emph)3$emphend and <br/>
  62.  $(emph)a2$emphend has value $(emph)pi$emphend, <br/>
  63.  then the string<pre>
  64.  $$(a$$[$$i-1])*x+$$(a$$[$$i-2])</pre>will become<pre>
  65.  pi*x+3</pre>after substitution.
  66. </li><li>If the value of a variable being substituted contains the character
  67.  $emph$$$emphend, this value will again be substituted, until no more
  68.  substitution is needed. The server has a built-in limit of nested
  69.  substitutions; infinite nested substitions will violate this limit and
  70.  generate an error message.
  71.  </li>
  72. </ul>
  73.  
  74. <hr/>
  75. <h4>Reserved variable names</h4>
  76.  
  77. The following names are reserved for their special meanings. They should not be
  78. used for internal needs of any module.
  79.  
  80. <ul>
  81. <li>Do not use variables with names consisting only of numbers. They are
  82.  reserved for future enhancements of the language.
  83. </li><li>Variables named
  84.  !for i in cmd,module,session,lang,special_parm,user,useropts,worksheet
  85.   $emph$i$emphend,
  86.  !next i
  87.  are reserved for special parameter passed by the user. A module's variable
  88.  processing file or phtml file can read but cannot set them. <br/>
  89.  Refer to the section $emph$title_structure$emphend for the meaning of
  90.  these variables.
  91. </li><li>The variable $emph no_name$emphend has a special use: <br/>
  92.  Parameters in the user query string with no name (for example when the
  93.  coordinate of a mappable image is passed this way to the http server) will
  94.  be registered under this variable. For this reason, it should not be used
  95.  for other purposes.
  96. </li><li>All variable names starting with $emph wims_$emphend will have special
  97.  meanings for wims server. A module should read or write them only for the
  98.  special meanings they are designed for.
  99. </li><li>Variable names starting with $emph m_$emphend are reserved for inline
  100.  mathematical fonts. The module programmer may redefine them, but then their
  101.  original meaning will be lost.
  102. </li><li>The variable $emph module_dir$emphend has a value preset to the directory
  103.  of the current module (with respect to the public home directory of the
  104.  server). This value is usually $emph $$module_dir=module/$$module $emphend
  105.  (but may vary with the config of the installation).
  106. </li><li>Variable names starting with $emph module_$emphend will have special
  107.  meanings: they are used to hold variables defined in the module's INDEX
  108.  file. Currently implemented variables:
  109.  
  110.  $table_header
  111.  $table_tr<th> Variables</th><th>Meaning</th></tr>
  112.   $table_tr<td>$emph module_title$emphend</td><td>title of the module</td></tr>
  113.   $table_tr<td>$emph module_description$emphend</td><td>short description of the module</td></tr>
  114.   $table_tr<td>$emph module_author$emphend</td><td>name(s) of author(s) of the module</td></tr>
  115.   $table_tr<td>$emph module_address$emphend</td><td>e-mail address of the (principal) author</td></tr>
  116.   $table_tr<td>$emph module_maintainer$emphend</td><td>name of the current maintainer</td></tr>
  117.   $table_tr<td>$emph module_maintainer_address$emphend</td><td>e-mail address of the maintainer</td></tr>
  118.   $table_tr<td>$emph module_copyright$emphend</td><td>copyright notice of the module</td></tr>
  119.   $table_tr<td>$emph module_version$emphend</td><td>current version of the module</td></tr>
  120.   $table_tr<td>$emph module_wims_version$emphend</td><td>minimal wims version required<br/>
  121.         to run this module</td></tr>
  122.   $table_tr<td>$emph module_language$emphend</td><td>language of the module<br/>(en, fr, de, or ...)</td></tr>
  123.   $table_tr<td>$emph module_category$emphend</td><td>category of the module<br/>
  124.         (exercise, tool, course, pedia, recreation, adm, other)</td></tr>
  125.   $table_tr<td>$emph module_level$emphend</td><td>level of the module</td></tr>
  126.   $table_tr<td>$emph module_domain$emphend</td><td>algebra, analysis, geometry, ...</td></tr>
  127.   $table_tr<td>$emph module_keywords$emphend</td><td>keywords, to be placed in the html header</td></tr>
  128.   $table_tr<td>$emph module_scoring$emphend</td><td>= yes if the module gives scores according to wims standard</td></tr>
  129.   $table_tr<td>$emph module_data$emphend</td><td>address of datamodule</td></tr>
  130.  
  131.  $table_end
  132.  Also, variables $emph module_has_intro$emphend,
  133.  $emph module_has_help$emphend and
  134.  $emph module_has_about$emphend
  135.  have value "yes" if the module's directory contains the respective
  136.  .phtml file. These variables are used in the command <span class="tt">!homeref</span>.
  137. </li><li>Some environment variables setup by httpd are readable by wims
  138.  modules under names starting with $emph httpd_$emphend. For example, the
  139.  environment variable $emph REMOTE_HOST$emphend becomes
  140.  $emph httpd_REMOTE_HOST$emphend under wims. <br/>
  141.  Please refer to httpd protocol specifications for details of such variables.
  142. </li><li>All variable names starting with $emph ins_$emphend, $emph
  143.  insplot_$emphend, $emph instex_$emphend will have special meanings for the
  144.  corresponding dynamic insertion engines. A module should read or write them
  145.  only for the special meanings they are designed for.
  146. </li><li>If your module uses an external package (e.g. $emph pari$emphend),
  147.  variable names starting with the name of the interface to that external
  148.  package followed by $emph _$emphend will have special meanings for that
  149.  interface, and should be reserved for that purpose.
  150.  </li>
  151. </ul>
  152.