webMathematica >

MSPBlock

MSPBlock[{vari, ...}, body]
interpret the argument variables and replace in the body
MSPBlock[{vari, ...}, body, defvalue]
if any of the variables do not have values, defvalue is returned
  • This is one of the key ways to work with variables from the HTTP request.
  • MSPBlock takes each of the variables var_i, interprets them, and then replaces any occurrences in body with the interpreted value.
  • If any variables do not have values, an empty string is returned.
  • The following exceptions can be thrown by MSPBlock.
MSPException["ParseError"]if the value cannot be interpreted by Mathematica
MSPException["SecurityError"]if the value does not pass the security test
MSPException["ValueError"]if the value is not a string, this indicates a programmatic error by the page author
MSPException["VariableError"]if the variable is not a Mathematica symbol, this indicates a programmatic error by the page author
You can simulate how the functions work by loading the package and setting the security content.
In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Here the variable $$var is assigned to the value "5+7"; note that the value is a string.
In[3]:=
Click for copyable input
When MSPBlock evaluates, all occurrences of $$var are replaced by its interpreted value.
In[4]:=
Click for copyable input
Out[4]=
If the input value cannot be interpreted, an MSPException is thrown.
In[5]:=
Click for copyable input
In[6]:=
Click for copyable input
Out[6]=
If the input value does not pass the security test, an MSPException is thrown.
In[7]:=
Click for copyable input
In[8]:=
Click for copyable input
Out[8]=
Input can also be given in MathML.
In[9]:=
Click for copyable input
In[10]:=
Click for copyable input
Out[10]=