DocumentTools[Canvas][Script]
ToString
set the contents of a math canvas element
Calling Sequence
Parameters
Description
Examples
Compatibility
ToString(script)
script
-
DocumentTools:-Canvas:-Script object
The ToString command converts the given script object to an XML string that can be used as the return value of a button-press in Maple Learn.
In this example, we will create a script that modifies math on a canvas
with⁡DocumentTools:-Canvas:
This is the procedure that will be called when we click the button. Note that the last line of this procedure is a call to ToString(script), which is essential in order for this to work in Maple Learn
Complexify := proc( canvas ) uses DC=DocumentTools:-Canvas; randomize(); local script := DC:-Script(); for local m in DC:-GetMath(canvas,'inert') do # get all the math in the canvas SetActive(script,m); # set the location of the annotation local newexpr := RandomTools:-RandomExpand(m:-math); SetMath(script,newexpr); end do; ToString(script); end proc:
Create and deploy the canvas
cv ≔ NewCanvas⁡Write some expressions anywhere, then press the button to 'complexify' your input into something equivalent but more complicated!,ScriptButton⁡Complexify,Complexify:
ShareCanvas⁡cv
The DocumentTools[Canvas][Script][ToString] command was introduced in Maple 2021.
For more information on Maple 2021 changes, see Updates in Maple 2021.
See Also
Math
NewCanvas
Script
SetActive
SetText
Download Help Document
What kind of issue would you like to report? (Optional)