Subversion Repositories wimsdev

Rev

Rev 2753 | Rev 4051 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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