11.07.2015 Views

webMathematica™ Wolfram - Wolfram Research

webMathematica™ Wolfram - Wolfram Research

webMathematica™ Wolfram - Wolfram Research

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

webMathematica User Guide 159An alternative way to interpret input is to use MSPToExpression. This can use page variables tohold the result of interpretation. It is not quite as neat as the use of MSPBlock, but is somewhatmore expressive. Here is an example.poly = Null;exponent = Null;If[ MSPValueQ[ $$expr, $$num],poly = MSPToExpression[ $$expr] ;exponent = MSPToExpression[ $$num]] ;If[ poly =!= Null && exponent =!= Null,Expand[ poly^exponent]]This example shows how webMathematica extracts the interpreted value of $$expr and stores itwith the page variable poly. This is especially useful if you use the interpreted value in a numberof different places.Page VariablesStandard Mathematica programming constructs such as Block, Module, and Function all workin their typical ways with regard to localization and scoping issues. You can find more informationon their operation in standard Mathematica references.You can use variables in Mathematica code inside of msp:evaluate tags; they can store intermediatevalues and be used for computation. Since these variables will be cleared when the kernelis cleared, it is not important to put these variables into a normal Mathematica program structuresuch as Module or Block. Consequently these are called page variables.In the example below the page variable tmp holds the value Null; it then gets the result ofcalling MSPToExpression on the input variable $$expr. If MSPToExpression was unable tocomplete its task, for example, because of a security error, it will throw an exception and tmpwill still have the value Null. Later, if tmp is not set to Null, you can be certain that the inputwas processed without problems and you can use it for calculations.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!