DocumentTools/Canvas/Script/ToString - Maple Help

Home : Support : Online Help : DocumentTools/Canvas/Script/ToString

DocumentTools[Canvas][Script]

 ToString
 set the contents of a math canvas element

 Calling Sequence ToString(script)

Parameters

 script - DocumentTools:-Canvas:-Script object

Description

 • 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.

Examples

In this example, we will create a script that modifies math on a canvas

 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Canvas}\right):$

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

 > $\mathrm{cv}≔\mathrm{NewCanvas}\left(\left["Write some expressions anywhere, then press the button to \text{'}complexify\text{'} your input into something equivalent but more complicated!",\mathrm{ScriptButton}\left("Complexify",\mathrm{Complexify}\right)\right]\right):$
 > $\mathrm{ShareCanvas}\left(\mathrm{cv}\right)$

Compatibility

 • The DocumentTools[Canvas][Script][ToString] command was introduced in Maple 2021.
 • For more information on Maple 2021 changes, see Updates in Maple 2021.