WIMS

WWW Interactive Multipurpose Server


Liste des commandes utilisable dans le langage WIMS
Commande Type Aliases Syntaxe Explication
append both execution and variable command   !append object s1 to str String manipulation: append object s1 to the string str. object maybe item, word or line.
bound execution command   !bound vname between [integer] v1 and v2 [default defaultvalue]
or
!bound vname within list [default defaultvalue]
bound the range of the variable vname. Usually this is used on user-submitted variables.
The first syntax is usually for numerical variables (integer or real, defaults to real). In this case v1 and v2 supplies the lower and upper bounds for the value of vname.
In the second syntax, the value of vname is compared with each item of list. If no occurrence is found, the value of vname is replaced either by defaultvalue or the first item of list, according to whether defaultvalue is defined.
In any case, defaultvalue is optional.
changeto execution command   !changeto file [ parm] Abandon the current file, changing processing to file. file is as in read.
And the parameter parm can be accessed from within the new file under the variable name wims_read_parm.
char both execution and variable command Aliases : chars !char numlist of string Outputs selected characters of string, according to numlist.

numlist can be a single integer, a comma-separated list of integers, or a range of integers.
A positive integer denotes the number of character in string counted from the beginning, with 1 corresponding to the first character. A negative integer denotes the number of character from the end of string: -1 means the last character, -2 means the next-to-last character, etc.

The syntax for a range of integers is

 n1 to n2
For example, 2 to -2 means the whole string except the first and the last characters.
charcnt variable command Aliases : charcount, charno, charnum, lengthof !charcnt string Returns the number of characters in string.
checkdata variable command Aliases : checkdatamodule !checkdata This command is used to check whether datamodules required by the present module are installed on the server. It returns "yes" if every required datamodule is installed or if no datamodule is required. Otherwise it returns the address of the first missing datamodule.

If your module depends on datamodules to run, declare them in the INDEX file, then use this command to check the presence of the datamodules. If the answer is "no", you can take actions to lock further access to your module and/or show error messages.

column both execution and variable command Aliases : columns !column numlist of string Outputs selected (comma-separated) columns of a matrix string, according to numlist. Rows of the matrix can be separated either by new lines or by semi-colon ``;''.

numlist can be a single integer, a comma-separated list of integers, or a range of integers.
A positive integer denotes the number of column in string counted from the beginning, with 1 corresponding to the first column. A negative integer denotes the number of column from the end of string: -1 means the last column, -2 means the next-to-last column, etc.

The syntax for a range of integers is

 n1 to n2
For example, 2 to -2 means the whole string except the first and the last columns.

The output is separated by commas if only one column is selected, or separated in the same way as the matrix string otherwise.

date both execution and variable command   !date parm This is simply an interface to the Linux date utility. parm is the parameter string to the Linux command date, please refer to the man page of date for its syntax. The command returns the output of the date utility.
deaccent both execution and variable command   !deaccent string Returns string with all accented letters (such as é, à, ï) folded to their unaccented counterparts.
debug both execution and variable command   !debug parms This command is for debugging purposes: it substitutes the parameter parms, and stops the execution with a module error sent to the user. The content of the error message contains the result of the substitution.
declosing both execution and variable command   !declosing string Strips off enclosing pair of parentheses ((),[],{}) in string. Useful for treatment of user-input vectors or sets, where some users use enclosing parentheses and other don't.
default execution command   !default name=value
put value into the variable name, if name is not already defined.
value may be a variable command (together with optional parameters).
defof both execution and variable command Aliases : definitionof, getdef !defof vname in fname Returns the definition of variables vname in the file fname.

When vname contains several names, the values of each will be returned with the same separators as for the names.

detag both execution and variable command   !detag string Removes html tags in string. It is very rudimentary and should be used with care. Very useful for security enhancement in some occasions (apply to user-supplied strings).
distribute execution command   !distribute type string into namelist Distribute the content of string into variables namelist. The distribution can be done word by word, item by item, character by character or line by line, according to the word type. type can be one of the following: words, items, lines, chars.

For example, if type is words, then the first (resp. second, etc.) variable in namelist will be set to the first (resp. second, etc.) word of string.

embraced both execution and variable command   !embraced opword string executes an operation opword in each substring of string enclosed in a pair of curly braces.

The curly braces in string can be nested, but the execution runs from outmost pair to innermost pair.

Available opword:

  • randitem. Random item in every embraced text.
  • extract. Extracts the first (outmost) embraced text.
  • delete. Deletes all embraced contents (encluding the curly braces).
eval variable command Aliases : evalue !eval expr Returns the numerical value of the expression expr. expr must evaluate to a real number (under the current version of wims). The evaluation is internally done in double precision, but the print precision can be changed by setting the variable wims_print_precision (whose default value is 8).
If an error is found in the expression expr, 0 is returned. (I know that this is very bad; I just have no time to make everything right.)
evalsubst both execution and variable command Aliases : evalsubstit, evalsubstitute, evaluesubst, evaluesubstit, evaluesubstitute !evalsubst name=val in expr Manipulation of mathematical expressions: substitute variable name by val in expr, then evaluate the expression to a real number.
No regular expression is allowed in name.
See also the commands !mathsubst, !replace.
exchange execution command   !exchange var1 and var2
or exchange var1, var2
Exchanges the values of the variables var1 and var2.
exec both execution and variable command Aliases : execute, run, call !exec command parms execute external command command with optional parameters parms. command must be a valid program name in the wims-public directory bin.
When used as variable command, returns the output of the called program.
exit execution command Aliases : return !exit Abandon the current file. If current file is called by another file, return to the latter.
fileappend execution command Aliases : appendfile !fileappend fname content Append content to file fname. fname is a file residing in the module's directory, under the subdirectory writable.
A new line will be added at the end of the content.

Special case: if the file name starts with getfile/, the file is written to the getfile subdirectory of the session. This file is then accessible via the command

!href cmd=getfile&special_parm=fname_without_getfile_prefix
, or a complete url
$wims_ref_name?session=$session&cmd=getfile&special_parm=fname_without_getfile_prefix
filewrite execution command Aliases : writefile !filewrite fname content Write content to file fname. fname is a file residing in the module's directory, under the subdirectory writable.
A new-line character will be added at the end of the content.

Special case: if the file name starts with getfile/, the file is written to the getfile subdirectory of the session. This file is then accessible via the command

!href cmd=getfile&special_parm=fname_without_getfile_prefix
, or a complete url
$wims_ref_name?session=$session&cmd=getfile&special_parm=fname_without_getfile_prefix
for execution command   !for var = start to end [step st ]
or !for var from start to end [step st ]
or !for var in list
... (multi-line content)
!next
For loop. In the first two forms, var goes from start to end, with optional step st.
In the last form, var takes successively items in the list list. list is a list of items separated by commas.
The command
!break
within the for loop breaks it. continue is not yet implemented in this version.
It is recommended that the variable name var be added to the !next line. This has no effect for the time being, but may be used in future versions of wims.
form execution command   !form cmdvar Creates a html form pointing to the wims server.
Whenever possible, this command should be used instead of a direct use of html tag <form>.
This command will create a <form> tag pointing to the wims server, adding <input> fields to pass session number (and other reserved things in the future). In lines which follow, other input (or select) fields may be added to the form. A final </form> tag should also be added by the programmer.
cmdvar is an optional parameter. Its value should be a valid value for the variable cmd. In this case the value cmdvar will be automatically submitted to the variable cmd . If this parameter is missing or is invalid, then the programmer should add a <input type=hidden name=cmd value=...> tag before the final </form>.

The target of the form can be controlled by the variable wims_ref_target. It can also be defined via an optional word target=.... Note that in this case the target must start with wims_.

The variable wims_form_method which must be either `get' or `post' controls the method of the form. This method defaults to `post' for tool modules, and to `get' for all other modules.

formbar execution command Aliases : formradiobar, htmlbar, htmlradiobar !formbar name from n1 to n2
or
!formradio name list selectlist
Creates a bar of radio buttons under a previously defined html form.
This bar should be arranged to represent values from small to big. No prompt is given to the user, except the indication that left is smaller. In the parameters, name defines the name field of the menu, and the values of the menu are either integers going from n1 to n2 (in the first syntax), or items in the list selectlist.
The default of the menu will be the current value of the variable $name.
formcheckbox execution command Aliases : htmlcheckbox !formcheckbox name from n1 to n2 prompt promptlist
or
!formcheckbox name list selectlist prompt promptlist
Creates a checkbox list menu under a previously defined html form.
This command speeds up the creation of checkboxed menus, as well as simplifies the source files. In the parameters, name defines the name field of the menu, and the values of the menu are either integers going from n1 to n2 (in the first syntax), or items in the list selectlist.
The optional parameter promptlist can be used to generate user prompts for each items in the list. If promptlist is empty or is shorter than selectlist, the undefined prompts will be replaced by the value. If it is longer, the rest will be ignored.
The default of the menu will be the current value of the variable $name.
formradio execution command Aliases : htmlradio !formradio name from n1 to n2 prompt promptlist
or
!formradio name list selectlist prompt promptlist
Creates a radio button list menu under a previously defined html form.
This command speeds up the creation of radio buttoned menus, as well as simplifies the source files. In the parameters, name defines the name field of the menu, and the values of the menu are either integers going from n1 to n2 (in the first syntax), or items in the list selectlist.
The optional parameter promptlist can be used to generate user prompts for each items in the list. If promptlist is empty or is shorter than selectlist, the undefined prompts will be replaced by the value. If it is longer, the rest will be ignored.
The default of the menu will be the current value of the variable $name.
formselect execution command Aliases : htmlselect !formselect name from n1 to n2 prompt promptlist
or
!formselect name list selectlist prompt promptlist
Creates a select menu under a previously defined html form.
This command speeds up the creation of select menus, as well as simplifies the source files. In the parameters, name defines the name field of the menu, and the values of the menu are either integers going from n1 to n2 (in the first syntax), or items in the list selectlist.
The optional parameter promptlist can be used to generate user prompts for each items in the list. If promptlist is empty or is shorter than selectlist, the undefined prompts will be replaced by the value. If it is longer, the rest will be ignored.
The default of the menu will be the current value of the variable $name.
The variable wims_formselect_switch may be used to set switches (for example by letting wims_formselect_switch=multiple, the selection will be multiple.
getopt both execution and variable command   !getopt name in string This command allows to extract the definition of a word in string under the form name=value.

It returns the defined value in the string, or the name itself if it appears in string but if there is no = sign following it, or an empty string if name does not appear in string as a word.

value can be a multi-word string, if it is enclosed by a pair of parentheses, brackets, curly braces or double quotes. The enclosing parentheses etc. will be removed from the output.

Spaces are allowed before and/or after the = sign.

goto execution command   !goto label Unconditionally jump to label . label must be a valid label in the current file.
header execution command Aliases : htmlheader, wimsheader !header parm Standardized header for html page outputs. Includes the variable wims_html_header and the commands !headmenu and !title.

parm is reserved for future implementation.

headmenu execution command   !headmenu Creates a standardised menu bar, usually to be included on the top of the page.
hex both execution and variable command Aliases : tohex !hex string Returns a new string replacing every character in string by its hexadecimal code.

In particular, the result can be used as part of a variable name whatever the content of string is (as long as it is not too long).

homeref execution command Aliases : wimsref !homeref parm Creates a standardised table of links to wims homepage (and eventually other things).
parm is reserved for future implementation.
href execution command   !href parms text Creates a hypertext reference pointing to the wims server.
Whenever possible, this command should be used instead of a direct use of html tag <a href=...>.
parms is the string of parameters to the call to wims server, which should not contain white spaces. Usually a cmd=... pair should be at least present; on the other hand, the session number and prefered language will be directly added by the server.
text is the text on which the hypertext link sits. It can be any text or a <IMG ...> tag, but dynamic insertions are not accepted yet.
There is no need to add the end tag </a>.

The target of the reference can be controlled via the variable wims_ref_target. It can also be defined via an optional word target=.... Note that in this case the target must start with wims_.

htmlmath both execution and variable command   !htmlmath expr Translate the raw mathematical expression expr, into a form which can be best possibly rendered via html tags.
if execution command   !if string1 relation string2
... (multi-line content)
!endif
Conditional branching: execute the multi-line content between !if line and !endif line, if relation is verified. The leading and trailing spaces of string1 and string2 will be stripped before making comparisons.

Toutes les comparaisons sont faites sur des chaînes de caractères : string1 rel string2. Plusieurs comparaisons peuvent être reliées par les opérateurs and et or. Les parenthèses sont alors utilisées pour construire des expressions logiques complexes de comparaison.

Relations rel :
relation condition
= or == vrai si string1 et string2 sont identiques.
!= or <> vrai si string1 et string2 ne sont pas identiques.
< vrai si l'évaluation numérique de string1 est strictement inférieure à celle de string2
<= <= & l'évaluation numérique de string1 est inférieure ou égale à celle de string2.
> vrai si l'évaluation numérique de string1 est strictement supérieure à celle de string2.
>= l'évaluation numérique de string1 est supérieure à celle string2.
isin vrai si string1 est une sous-chaîne de caractères de string2.
notin string1 n'est pas une sous-chaîne de caractères de string2.
iswordof vrai si string1 est un mot de string2.
notwordof vrai si string1 n'est pas un mot de string2.
isvarof vrai si string1 est une variable mathématique de l'expression string2.
notvarof vrai si string1 n'est pas une variable mathématique de l'expression string2.
isvariableof vrai si string1 est une variable mathématique de l'expression string2.
notvariableof vrai si string1 n'est pas une variable mathématique de l'expression string2.
isitemof vrai si string1 est un item de la liste string2.
notitemof vrai si string1 n'est pas un item de la liste string2.
islineof vrai si string1 est une ligne de string2.
notlinedof vrai si string1 n'est pas une ligne de string2.
issamecase vrai si string1 et string2 sont les mêmes textes à des espaces multiples près, mais tenant compte de la casse des lettres.
notsamecase vrai si string1 et string2 ne vérifient pas le critère ci-dessus .
issametext vrai si string1 et string2 sont les mêmes textes à des espaces multiples près, à la casse près et aux lettres accentuées près.
notsametext vrai si vrai si string1 et string2 ne vérifient pas le critère précédent.
ifval execution command Same as the command if, but = (==), != compares the numerical values of string1 and string2 rather than the strings themselves.
increase execution command Aliases : advance !increase var Increase the value of var by one. The value of var is first rounded to an integer.
insdraw execution command (only valid for phtml files) Aliases : inspaint !insdraw drawsource The server will call a paint program ( flydraw), submit drawsource as its command (with variables substituted), and insert the result into the page.
insmath execution command (only valid for phtml files)   !insmath formula According to the complicatedness of formula , the server will either render it as beautifully as possible using html tags, or translate formula into TeX source then call TeX to compile and finally transform the TeX result into a picture. The latter is inserted into the page (at the place of the command).
If the user browser knows mathml, then the formula is simply translated into mathml and sent to the browser.
insplot execution command (only valid for phtml files)   !insplot plotsource The server program will call an external plotting program (gnuplot for the current version), submit plotsource as the 2D plot command (with variables substituted), and insert the result into the page.
The syntax of plotsource is that of the plot command of gnuplot.
insplot3d execution command (only valid for phtml files)   !insplot3d plotsource As for insplot, but plotsource is in the syntax of the splot command of gnuplot, and a 3D surface will be plotted.
instex execution command (only valid for phtml files)   !instex texsource The server program will call TeX to process the (plain) TeX source texsource (after variable substitution), translate the result into a picture, and insert it into the page (at the place of the command).
A tip: avoid using substituted variables in texsource whenever possible. In this case Wims will use static instex, improving performance dramatically over dynamic instex.
The font color of the inserted text can be controled either by the variable instex_color, or by a \special{color=...} string in the texsource.
instexstatic execution command (only valid for phtml files) Aliases : instexst, staticinstex, stinstex !instexstatic gifname texsource This command is obsolete, and will be dropped in future versions. Use !instex instead.
item both execution and variable command Aliases : items !item numlist of string Outputs selected (comma-separated) items of string, according to numlist.

numlist can be a single integer, a comma-separated list of integers, or a range of integers.
A positive integer denotes the number of item in string counted from the beginning, with 1 corresponding to the first item. A negative integer denotes the number of item from the end of string: -1 means the last item, -2 means the next-to-last item, etc.

The syntax for a range of integers is

 n1 to n2
For example, 2 to -2 means the whole string except the first and the last items.
itemcnt variable command Aliases : itemcount, itemno, itemnum !itemcnt list Returns the number of items in list.
items2lines both execution and variable command Aliases : itemstolines, list2lines, listtolines !items2lines string This command changes multiple items in string into multiple lines.
items2words both execution and variable command Aliases : itemstowords, list2words, listtowords !items2words string This command changes multiple items in string into multiple words.
let execution command Aliases : def, define, set !let name=value
put value into the variable name.
value may be a variable command (together with optional parameters).
leveldata both execution and variable command Aliases : levelpoints !leveldata size xsize,ysize ranges x1,x2,y1,y2 function f(x,y) [levels l1,l2,...] Computes coordinates of points on the level curve of f(x,y), at levels l1,l2,... (defaults to one level 0).

The computation is made from (x1,y1) to (x2,y2), and points are computed as integer positions in a picture with size xsize,ysize.

Order of the fields is not important. All the fields except levels are mandatory.

line both execution and variable command Aliases : lines !line numlist of string Outputs selected lines of string, according to numlist.

numlist can be a single integer, a comma-separated list of integers, or a range of integers.
A positive integer denotes the number of line in string counted from the beginning, with 1 corresponding to the first line. A negative integer denotes the number of line from the end of string: -1 means the last line, -2 means the next-to-last line, etc.

The syntax for a range of integers is

 n1 to n2
For example, 2 to -2 means the whole string except the first and the last lines.
linecnt variable command Aliases : linecount, lineno, linenum !linecnt string Returns the number of lines in string.
lines2items both execution and variable command Aliases : linestoitems, lines2list, linestolist !lines2items string This command changes multiple lines in string into multiple items.
lines2words both execution and variable command Aliases : linestowords !lines2words string This command changes multiple lines in string into multiple words.
listcomplement both execution and variable command   !listcomplement list1 in list2 Returns items appearing in list2 but not in list1. Repetitive occurrences are eliminated.
listfile both execution and variable command Aliases : listfiles, filelist, ls, dir !listfile filespec list files specified in filespec. Options to Linux command ls are accepted. The base directory is the base of the wims server. So if you want to list files in the current module, type
!listfile $module_dir

Only trusted modules can use this command.

listintersect both execution and variable command Aliases : listintersection !listintersect list1 and list2 Returns items appearing in both list1 and list2. Repetitive occurrences are eliminated.
listunion both execution and variable command   !listunion list1 and list2 Returns items appearing in either list1 or list2. Repetitive occurrences are eliminated.
listuniq both execution and variable command Aliases : listunique !listuniq list Returns items in list, with repetitive occurrences eliminated.
lookup both execution and variable command   !lookup defname in fname Returns the definition of word defname in the file fname which must be a dictionary file in the same syntax as for the program translator (not necessarily sorted).

fname may be either in the module directory (in this case the module directory need not be specified), or in the directory bases/.

lower both execution and variable command Aliases : lowercase, tolower !lower string Returns string with all upper case letters replaced by their lowercase counterparts.
mailto
This command is only available for trusted modules of the site.
execution command   !mailto ... sends a email to a person whose address is the first line of the parameter.
The second line is the subject of the message.
And the rest is the body of the message.
mailurl both execution and variable command   !mailurl address name ... Creates a javascript-crypted email interface that is difficult for spammer-robot to decrypt.

The first word of the first line in the parameter should be the email address.
The rest of the first line is the recepient name (default to email address).
The second line and up is the mail subject.

This command calls, in the order of priority, one of the following files:

  1. "mailurl.proc" in the module directory.
  2. "mailurl.proc" in the current theme.
  3. "scripts/mailurl.proc".
This allows site managers and authors to define different address encryption methods.
Mail addresses are not encrypted when the user is within a virtual class.
This command collapses some variables beginning with "mailurl_".
makelist both execution and variable command   !makelist templ for v= v1 to v2 [step st ], or
!makelist templ for v in v1,v2,v3,...
Outputs a list consisting of templ with variable v successively substituted by values v1, ..., v2.

In the second syntax, the substitutions are done with respect to each item in the list v1,v2,....

The variable v should appear in templ as a math variable (that is, with no preceeding character).

For example, the command

!makelist [x;x+1;xx] for x in a,x and y,1,(2,3)
gives the result
[a;a+1;xx],[x and y;x and y+1;xx],[1;1+1;xx],[(2,3);(2,3)+1;xx]  
mathsubst both execution and variable command Aliases : mathsubstit, mathsubstitute !mathsubst name=val in expr Manipulation of mathematical expressions: substitute variable name by val in expr.
No regular expression is allowed in name.
See also the commands !evalsubst, !replace.
mexec
This command is only available for trusted modules of the site.
both execution and variable command   !mexec command parms execute a module-private external command command with optional parameters parms. command must be a valid program name in the module's home directory. But the command is executed from the base directory of the server.
When used as variable command, returns the output of the called program.
module both execution and variable command   !module defname modname Returns the definition for defname of the module modname. The most common use of this command is to get the title of a module ( defname=title).
The INDEX file of the module modname will be parsed to look for the definition of defname.
msg execution command   !msg error [ parm] Put an error message of type error, with eventual parm depending on error.
nonempty both execution and variable command Aliases : non_empty !nonempty obj content obj can be item or line. The non-empty items or lines in content will be extracted.
nospace both execution and variable command   !nospace string Collapses all space characters (' ', tab, newline) in string.
nosubst variable command   !nosubst string Returns string `as-is', without variable substitution.
pedia both execution and variable command Aliases : encyclopedia, encyclo !pedia keyword, name Creates a hypertext link pointing to an online encyclopedia.
keyword will be the name under which the reference is looked for, and should be a phrase with one or several words separated by space. Examples: finite field or linear transformation.
name is the name of the link (i.e. what people see in their page, and can click on).

Actually wims use Wikipedia as the standard reference encyclopedia.

positionof both execution and variable command Aliases : position, positions !positionof [type] s in string
Reports the positions of the object s in string.
type can be char, word, item or line. If it is specified, then the comparison only takes place for corresponding objects of string which are identical to s.
The output of the command is a list of positions (char, word, item or line, according to the value of type) where s is found in string.
If type is missing, then s is searched in string as a substring, and the positions reported are character positions.
product both execution and variable command Aliases : prod, multiply !product fn for v= v1 to v2 [step st ], or
!product fn for v in v1,v2,v3,...
Computes the product of a function fn(v) with variable v replaced successively by values v1, ..., v2.

In the second syntax, the values are given with respect to each item in the list v1,v2,....

randchar variable command   !randchar str Returns a random character in str.
randfile variable command Aliases : randrecord !randfile fname Returns a random record in the datafile fname.

A datafile is a plain text file whose content is split into a number of records. Records are separated by tag strings "\n:" (a new-line character immediately followed by `:'). Lines before the first tag string are treated as comments.

randint variable command   !randint n1 , n2 Returns a random integer between n1 and n2 (inclusive).
Substitution and evaluation are done on n1 and n2 before applying random.
If n2 is missing, returns random integer between ±1 and n1 (inclusive).
If both n1 and n2 are missing, returns 0.
You can also type !random n1,n2 repeat i to repeatedly generate i random numbers.
randitem variable command   !randitem list Returns a random item in list. (Items are separated by commas.)
randline variable command   !randline str Returns a random line in str.
random variable command Aliases : randdouble, randfloat !random n1 , n2 Returns a random real number between n1 and n2 .
Substitution and evaluation are done on n1 and n2 before applying random.
If n2 is missing, returns random number between 0 and n1 .
If both n1 and n2 are missing, returns 0.
You can also type !random n1,n2 repeat i to repeatedly generate i random numbers.
randword variable command   !randword str Returns a random word in str.
rawmath both execution and variable command   !rawmath expr Translate the mathematical expression expr, possibly with common user errors, into a machine-understandable mathematical expression.
It will replace (x+1)(x-1) into (x+1)*(x-1), 5x^3 into 5*x^3, etc.
rawmatrix both execution and variable command   !rawmatrix expr Translate the matrix expr, possibly with common user errors, into a machine-understandable matrix expression.
reaccent both execution and variable command   !reaccent string Replace accented letter compositions in string by accented letters (replacing e' by é, a` by à, i" by ï, o^ by ô, etc.) The only exception is that ç and Ç are composed from c~ and C~ respectivement.
read execution command Aliases : include, input !read file [ parm] Insert the content of file, and process it. file must be a valid file name with the module's home directory as base directory. (directory structure may be specified in file, but backtracing to parent directories is prohibited.)
And the parameter parm can be accessed from within the called file under the variable name wims_read_parm.
WIMS will try to cache the file for repeated use, unless the filename is preceded by "./".
readproc execution command   !readproc file [ parm] Include a variable processing file file. file must be a valid file name with the module's home directory as base directory. (directory structure may be specified in file, but backtracing to parent directories is prohibited.)
And the parameter parm can be accessed from within the called file under the variable name wims_read_parm.
record both execution and variable command Aliases : records !record numlist of fname Outputs selected records of the datafile fname, according to numlist.

numlist can be a single integer, a comma-separated list of integers, or a range of integers.
A positive integer denotes the number of record in fname counted from the beginning, with 1 corresponding to the first record. A negative integer denotes the number of record from the end of fname: -1 means the last record, -2 means the next-to-last record, etc.

The syntax for a range of integers is

 n1 to n2
For example, 2 to -2 means the whole fname except the first and the last records.

A datafile is a plain text file whose content is split into a number of records. Records are separated by tag strings "\n:" (a new-line character immediately followed by `:'). Lines before the first tag string are treated as comments.

recordcnt variable command Aliases : recordcount, recordno, recordnum !recordcnt fname Returns the number of records in the datafile fname.

A datafile is a plain text file whose content is split into a number of records. Records are separated by tag strings "\n:" (a new-line character immediately followed by `:'). Lines before the first tag string are treated as comments.

recursion both execution and variable command   !recursion fn for v= v1 to v2 [step st ], or
!recursion fn for v in v1,v2,v3,...
Computes the outcome of a recursion using the function fn in which the variable v is replaced successively by values v1, ..., v2.

In the second syntax, the values are given with respect to each item in the list v1,v2,....

The function fn should use the variable last to indicate the value of the previous recursion step. And the starting value can be put into the WIMS variable $recursion_start.

reinput both execution and variable command   !reinput string Prepares string to be inserted into a form input or textarea.

Browsers translate & primitives into corresponding (special) characters even when these primitives occur in input or textarea fields. Also, if string contains html tags, they may confuse browsers. You can use this command on the string (usually derived from an earlier user input) before inserting them back into a input or textarea, to avoid the above problems.

rename both execution and variable command   !rename f Changes the reference to a file f, such as a graphics file reachable by direct http, into one with a different name using the method !getfile.

This command is useful with exercises where important information is carried by multimedia files (pictures, audios, movies). It can be used to hide the name of the multimedia file that otherwise would give clues to the solution of the problem.

The renamed file must be located within the module, and the filename f should start with $module_dir.

The command returns a string which is the new URL. The file is not effectively copied or renamed on the server.

replace both execution and variable command   !replace [internal] s1 by s2 in string
or !replace obj ident by s in string
String manipulation.

Under the first syntax, variable substitution is first done on string. Then all occurences of substring s1 are replaced by s2.
When the keyword internal is absent, the Linux utility sed is called to make the replacements, therefore regular expressions are accepted in s1 and s2. Please refer to the man page of sed for details.

Under the second syntax, obj can be char, word, item or line. Then the word, item or line identified by ident in string is replaced by s, after variable substitutions.
ident can be a string, in this case all objects (words, items or lines) matching ident will be replaced. It can also be a number (positive or negative integer n), preceded by the word number. In this case the object number n will be replaced. (In the case where n<0, it is the last -n'th object which is replaced.)

reset execution command   !reset name1 [ ,name2,...]
erase the content of the variable(s) name1, name2...
restart execution command   !restart parm Restart from a new request with parameters parm, usually for jumping to another module.

This command is only available to trusted modules, and can be only used before output starts. Repeated restart is disabled, to avoid infinite loops.

select both execution and variable command   !select data where condition Outputs rows of a matrix data, according to condition. Rows of the matrix can be separated either by new lines or by semi-colon ``;''.

The condition can use words column 1, column 2, etc. to designate comma-separated columns in each row.

setdef execution command   !setdef defstr in fname Set definitions defstr in the file fname.

defstr maybe multiple line, each being a definition string.

shuffle variable command Aliases : randperm, randpermute !shuffle [even|odd] n , or
!shuffle [even|odd] list
Randomly permutes a set of n elements. n must be a positive integer not greater than 1024 in the first usage, or is the number of items in list in the second usage.
For the first usage, the command returns a comma-separated list i1, i2, ..., in, where the items ik are randomly ordered elements of the set {1,2,...,n}.
This command can be used in conjunction with commands !item, !line, !word, !char, to randomly permute items, lines, words, or characters in a string.
For the second usage, a new list with randomly permuted items in list is returned.
In any case, the variable wims_shuffle_order is set to be the list i1, i2, ..., in.
When the optional word even or odd is present, only even/odd permutations are produced.
singlespace both execution and variable command   !singlespace string Returns string with all space characters (space, tab, newline) replaced by ' ', and multiple occurrences of space characters collapsed into single one.
Leading and ending spaces are not removed. You can use this command in conjunction with trim if you want also to remove leading and ending spaces.
This command is especially useful for comparisons between multi-word strings.
solve both execution and variable command Aliases : rootof !solve fn for v= v1 to v2 Find out (real simple) roots of the function/equation fn for the variable v between v1 and v2.

fn may have several roots in the interval [v1,v2], but roots too close to each other may be overlooked.

sort both execution and variable command   !sort [nocase] [reverse] [numeric] type [of] string Sort string. The type of the sort may be char, word, list or line.
After this command is executed, the sort order is stored in the variable wims_sort_order (as a list). This can therefore be used for relational sorting, in conjunction with commands !item, !line, !word or !char.
sum both execution and variable command Aliases : add !sum fn for v= v1 to v2 [step st ], or
!sum fn for v in v1,v2,v3,...
Computes the sum of a function fn(v) with variable v replaced successively by values v1, ..., v2.

In the second syntax, the values are given with respect to each item in the list v1,v2,....

tail execution command   !tail parm Standardized ending for html page outputs. Includes the command !homeref.

parm is reserved for future implementation.

texmath both execution and variable command Aliases : TeXmath !texmath expr Translate the mathematical expression expr into a TeX source.
text both execution and variable command   !text operation parameter This is intended to be a very powerful text manipulation tool, allowing very sophisticated processing of long text strings with high speed.
Many of the operations accept masks. A mask is a string composed of '0's and '1's. For operations which accept a mask, only characters at positions whose corresponding character in the mask is not a '0' are processed. (In this sense positions corresponding to '0's are masked.) Empty mask is considered as of being entirely composed of '1's.
A mask which is too short repeats itself, unless it terminates with a '+', in which case it fills the rest with '1's, or with a '-', in which case it fills the rest with '0's.
For the time being, implemented operations are as follows.
  • !text common text1 and text2 [mask maskstring]
    Extracts characters in text1 one by one, for those identical to the corresponding characters in text2 and whose positions are not masked by maskstring.
  • !text compare text1 and text2
    Compares the strings text1 and text2 character by character, and returns a mask string with '0's on positions where the corresponding characters in text1 and text2 are equal, and '1's otherwise.
  • !text copy text [mask maskstring]
    Returns non-masked characters in text.
  • !text count charlist in text [mask maskstring]
    Returns the number of characters in text whose positions are not masked by maskstring, and who appear in charlist.
  • !text diff text1 from text2 [mask maskstring]
    Extracts characters in text1 one by one, for those different to the corresponding characters in text2 and whose positions are not masked by maskstring.
    (Synonyme of diff: differ).
  • !text expand text using maskstring
    Produces a string, where positions corresponding to '0's in maskstring are filled by ' ' (the space character), and where positions corresponding to '1's in maskstring are filled by characters of text. The characters in text are used one by one, and the resulting string stops when all the characters in text are exhausted (or when the string reaches the length limit).
  • !text insert text1 into text2 [mask maskstring]
    Returns text2 with non-masked characters replaced by characters text1. Characters in text1 are used one by one (without taking into account the masking), and the replacement stops when there is no character left in text1.
  • !text interact text1 and text2 table itab [mask maskstring]
    Returns a new text which is result of interactions of characters in corresponding positions in text1 and text2. The rule of the interaction is defined in itab.
    itab contains n+1 lines, each of n characters. The first line defines the characters corresponding to each position in the following n lines which defines the multiplication table.
    The multiplication table needs not to be symmetric. In this case, the rows correspond to characters in text1, and the columns correspond to characters in text2.
    If text1 or text2 contains a character not in the first line of itab, the interaction at the corresponding position is considered as empty. Also, masked positions are ignored.
    If text1 and text2 have different lengths, the longer is cut to fit the shorter.
  • !text mark charlist in text
    Returns a mask string with '1's on positions where the corresponding character in text appears in charlist, and with '0's on other positions.
  • !text max text1 and text2 [mask maskstring]
    Returns a string which at each position is the character with highest ASCII code between corresponding characters in text1 and text2. The length of the result is that of the longest of the two. Masked positions are skipped.
  • !text min text1 and text2 [mask maskstring]
    Returns a string which at each position is the character with lowest ASCII code between corresponding characters in text1 and text2. The length of the result is that of the shortest of the two. Masked positions are skipped.
  • !text occur charlist in text [mask maskstring]
    Returns characters in charlist which occur in unmasked positions in text.
    (Synonymes of occur: appear, occurrence).
  • !text remove charlist in text [mask maskstring]
    Returns text in which masked characters and characters appearing in charlist are removed.
    (Synonymes of remove: drop, delete).
  • !text reorder text by orderlist
    Returns a reordered text using the order list orderlist. Reordering is cyclic if orderlist is shorter than text.
    orderlist must be a list of n positive integers, which is a permutation of the set {1,...,n}. If orderlist contains items other than integers within the bound, empty string is returned. However, unicity check is not performed on items of orderlist.
  • !text repeat text to len
    Repeat the string text cyclicly, up to length len.
  • !text reverse text
    Reverse the order of text, with the last character coming first, etc.
  • !text select charlist in text [mask maskstring]
    Returns text in which masked characters and characters not appearing in charlist are removed.
    (Synonymes of select: pick, pickup).
title execution command Aliases : htmltitle, wimstitle !title parm Puts page's title in a standardized format.

parm is reserved for future implementation.

translate both execution and variable command   !translate [internal] s1 to s2 in string
or !translate [internal] s1 in string to s2
String manipulation: variable substitution is first done on string. Then all occurences of the first (resp. second, ...) character of s1 is replaced by the first (resp. second, ...) character of s2.
When the keyword internal is absent, the Linux utility tr is called to make the translations, therefore regular expressions are accepted in s1 and s2. Please refer to the man page of tr for details.
trim variable command   !trim string Returns string with leading and trailing spaces stripped off.
upper both execution and variable command Aliases : uppercase, toupper !upper string Returns string with all lower case letters replaced by their uppercase counterparts.
values both execution and variable command   !values fns for v= v1 to v2 [step st ], or
!values fns for v in v1,v2,v3,...
Outputs a list of values of fns with variable v replaced successively by values v1, ..., v2.

In the second syntax, the values are given with respect to each item in the list v1,v2,....

fns may be a comma-separated list of functions.

This command can also be used to make recursions. If the functions fns contain a variable named last, this variable will take the value of the last step each time. And the starting value can be put into the WIMS variable $recursion_start.

varlist both execution and variable command Aliases : listvar !varlist [nofn] formula Manipulation of mathematical expressions: returns list of variable names (and function names) appearing in the formula.

If the switch nofn is present, function names will not be listed.

warn execution command Aliases : warning !warn subject Outputs a warning message related to subject. Does nothing if no warning message about subject is present.
while execution command   !while string1 relation string2
... (multi-line content)
!endwhile
Conditional branching: execute the multi-line content between !while line and !endwhile line, until relation is no longer verified. The leading and trailing spaces of string1 and string2 will be stripped before making comparisons.

The syntax is the same as for if.

whileval execution command
Same as the command while, but = ( ==), != compares the numerical values of string1 and string2 rather than the strings themselves.
word both execution and variable command Aliases : words !word numlist of string Outputs selected words of string, according to numlist.

numlist can be a single integer, a comma-separated list of integers, or a range of integers.
A positive integer denotes the number of word in string counted from the beginning, with 1 corresponding to the first word. A negative integer denotes the number of word from the end of string: -1 means the last word, -2 means the next-to-last word, etc.

The syntax for a range of integers is

 n1 to n2
For example, 2 to -2 means the whole string except the first and the last words.
wordcnt variable command Aliases : wordcount, wordno, wordnum !wordcnt string Returns the number of words in string.
words2items both execution and variable command Aliases : wordstoitems, words2list, wordstolist !words2items string This command changes multiple words in string into multiple items.
words2lines both execution and variable command Aliases : wordstolines !words2lines string This command changes multiple words in string into multiple lines.