In this example, we will define an application that allows user input and provides feedback. The FindPrimes procedure will run when a button is pressed. It will use the GetMath command to extract all of the math in the canvas area, then use Script commands, including Annotate to add annotations to the inputs.
>
|
FindPrimes := proc( canvas )
uses DC=DocumentTools:-Canvas;
local script := DC:-Script();
for local m in DC:-GetMath(canvas) do # get all the math in the canvas
SetActive(script,m); # set the location of the annotation
if m:-math::integer and isprime(m:-math) then
Annotate(script,"Good job, this is prime"); # annotate based on the given math
else
Annotate(script,"This is not prime");
end if;
end do;
ToString(script);
end proc:
|
Generate the canvas
>
|
|
>
|
|
To test this within Maple, run:
To try this on the web using Maple Learn, execute:
https://learn.maplesoft.com/#/?d=PKHUBIIINLGTCNLKJPERNOMOFJDQDFETEKNQIFHQGOMMKIAGJQFHFSOODNCPPGNKEMAMPGJRHTGIESNLLKNGBRFPGKDQOFBPEHOT