Rev 5798 | Rev 5921 | 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>. |
||
5798 | bpr | 12 | </p><p> |
32 | reyssat | 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.) |
||
5798 | bpr | 17 | </p><p> |
32 | reyssat | 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. |
||
5798 | bpr | 23 | </p><p> |
32 | reyssat | 24 | Special rules of variable substitution: |
5798 | bpr | 25 | </p> |
32 | reyssat | 26 | <ul> |
27 | <li>If the character $emph$$$emphend is followed by a space, it will be |
||
28 | discarded. |
||
5798 | bpr | 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 |
||
32 | reyssat | 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. |
||
5766 | bpr | 37 | <br/>Example: if the variable $(emph)i$emphend has value $(emph)3$emphend |
32 | reyssat | 38 | and the variable $(emph)alpha3beta$emphend has value $(emph)pi$emphend, |
4051 | bpr | 39 | the string<pre>3*$$(alpha$$(i)beta)*x</pre> |
40 | will become<pre>3*pi*x</pre> |
||
41 | after substitution. |
||
32 | reyssat | 42 | <p> |
43 | Array addressing: if the variable $(emph)l$emphend contains a |
||
44 | comma-separated list $(emph)a,b,c,d,e$emphend, then the string |
||
45 | <tt>$$(i[3])</tt> gives <tt>c</tt> after substitution, and |
||
46 | <tt>$$(i[2 to 4])</tt> tives <tt>b,c,d</tt>, etc. |
||
5798 | bpr | 47 | </p><p> |
5920 | bpr | 48 | Two-dimensional array addressing is also available: if</p> |
4051 | bpr | 49 | <pre>$$M=x,y,z;a,b,c</pre> |
32 | reyssat | 50 | (a 2x3 matrix), then |
4051 | bpr | 51 | <pre>$$(M[1;3,2])=z,y</pre> |
5798 | bpr | 52 | </li><li>If the character $emph$$$emphend is followed by the left bracket |
32 | reyssat | 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 |
||
5766 | bpr | 57 | together with the leading $emph$$$emphend. <br/> |
32 | reyssat | 58 | It can be used for array subscripts. |
5766 | bpr | 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/> |
||
32 | reyssat | 63 | then the string<pre> |
64 | $$(a$$[$$i-1])*x+$$(a$$[$$i-2])</pre>will become<pre> |
||
65 | pi*x+3</pre>after substitution. |
||
5798 | bpr | 66 | </li><li>If the value of a variable being substituted contains the character |
32 | reyssat | 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. |
||
5798 | bpr | 71 | </li> |
32 | reyssat | 72 | </ul> |
73 | |||
5920 | bpr | 74 | <hr/> |
5798 | bpr | 75 | <h4>Reserved variable names</h4> |
32 | reyssat | 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. |
||
5798 | bpr | 83 | </li><li>Variables named |
32 | reyssat | 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 passing by the user. A module's variable |
||
5766 | bpr | 88 | processing files or phtml files can read but cannot set them. <br/> |
32 | reyssat | 89 | Refer to the section $emph$title_structure$emphend for the meaning of |
90 | these variables. |
||
5798 | bpr | 91 | </li><li>The variable $emph no_name$emphend has a special use: <br/> |
32 | reyssat | 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. |
||
5798 | bpr | 96 | </li><li>All variable names starting with $emph wims_$emphend will have special |
32 | reyssat | 97 | meanings for wims server. A module should read or write them only for the |
98 | special meanings they are designed for. |
||
5798 | bpr | 99 | </li><li>Variable names starting with $emph m_$emphend are reserved for inline |
32 | reyssat | 100 | mathematical fonts. The module programmer may redefine them, but then their |
101 | original meaning will be lost. |
||
5798 | bpr | 102 | </li><li>The variable $emph module_dir$emphend has a value preset to the directory |
32 | reyssat | 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). |
||
5798 | bpr | 106 | </li><li>Variable names starting with $emph module_$emphend will have special |
32 | reyssat | 107 | meanings: they are used to hold variables defined in the module's INDEX |
108 | file. Currently implemented variables: |
||
1978 | bpr | 109 | |
110 | $table_header |
||
111 | $table_tr<th> Variables</th><th>Meaning</th></tr> |
||
5920 | bpr | 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 actual 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> |
||
2754 | bpr | 130 | |
5798 | bpr | 131 | </table> |
32 | reyssat | 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 <tt>!homeref</tt>. |
||
5798 | bpr | 137 | </li><li>Certain environment variables setup by httpd are readable by wims |
32 | reyssat | 138 | modules under names starting with $emph httpd_$emphend. For example, the |
139 | environment variable $emph REMOTE_HOST$emphend becomes |
||
5766 | bpr | 140 | $emph httpd_REMOTE_HOST$emphend under wims. <br/> |
32 | reyssat | 141 | Please refer to httpd protocol specifications for details of such variables. |
5798 | bpr | 142 | </li><li>All variable names starting with $emph ins_$emphend, $emph |
32 | reyssat | 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. |
||
5798 | bpr | 146 | </li><li>If your module uses an external package (e.g. $emph pari$emphend), |
32 | reyssat | 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. |
||
5798 | bpr | 150 | </li> |
32 | reyssat | 151 | </ul> |
152 |