This example defines a procedure that highlights parts of a math expression and provides information about variables and functions. Because it inserts new math between existing math boxes, it cannot be run using ShowCanvas. Note that changing where="below" to where="right" in the SetMath call will allow it to be run in Maple.
>
|
|
>
|
VarVersusFunc := proc(canvas)
local m := GetMath(canvas):
local sc := Script(':-canvas'=canvas):
for local mi in m do
SetActive(sc,mi);
local vars := indets(mi:-math,symbol):
for local v in vars do
Highlight(sc,v);
end do:
Annotate(sc,`if`(vars={},"no variables present","variables highlighted"));
SetMath(sc,mi:-math,where="below");
local funs := indets(mi:-math,function):
for local F in funs do
Highlight(sc,op(0,F));
end do:
Annotate(sc,`if`(funs={},"no functions present","functions highlighted"));
end do;
sc:-ToString(sc);
end proc:
|
For demonstration purposes, we will create a canvas with some math expressions already in it. Normally you would insert these yourself in Maple Learn
>
|
|
After editing the deployed canvas from the link above, you can share that canvas and assign the pasted string to the url variable below. Here we will use the canvas as deployed.
>
|
|
Execute the button press, and examine the generated script