Maplets[Elements]
Evaluate
specify command to run in Maple
Calling Sequence
Parameters
Description
Examples
Evaluate(opts, args)
opts
-
equation(s) of the form option=value where option is one of function, `option`, target, or waitforresult; specify options for the Evaluate element
args
(optional) Argument elements
The Evaluate command element runs a Maple procedure with the given set of arguments args in the underlying Maple session.
The Evaluate element features can be modified by using options. To simplify specifying options in the Maplets package, certain options and contents can be set without using an equation. The following table lists elements, symbols, and types (in the left column) and the corresponding option or content (in the right column) to which inputs of this type are, by default, assigned.
Elements, Symbols, or Types
Assumed Option or Content
x::{name, string} = y::anything
target = x, function = y
any other name or string
source option to an Argument element
An Evaluate element can contain Argument elements.
An Evaluate element can be contained in a Maplet element; in an equation for the onapprove, oncancel, onchange, onclick, ondecline, or onstartup option for an element; or wrapped in an Action element as a parameter in an element that accepts an onchange or onclick option without an equation.
The following table describes the control and use of the Evaluate element options.
An x in the I column indicates that the option can be initialized, that is, specified in the calling sequence (element definition).
An x in the R column indicates that the option is required in the calling sequence.
An x in the G column indicates that the option can be read, that is, retrieved by using the Get tool.
An x in the S column indicates that the option can be written, that is, set by using the SetOption element or the Set tool.
Option
I
R
G
S
function
x
`option`
target
waitforresult
The opts argument can contain one or more of the following equations that set Maplet application options.
function = string or anything
If the right-hand-side is of type string, it specifies the name of the procedure to be evaluated. Arguments args to the procedure specified in the right-hand-side must be included by using Argument elements. The arguments are passed in the order of the Argument element calls. For example, if there are two text fields with references TF1 and TF2, use:
Evaluate⁡function=diff,Argument⁡TF1,Argument⁡TF2
to execute the command diff(TF1, TF2) in the underlying Maple session. Note that this method can only be used for global procedures (in this case diff), as the function name is specified as a string. In addition, this approach allows for a single Argument to contain multiple comma separated values, so, for example the form:
Evaluate⁡function=diff,Argument⁡TF1
where TF1 contains f(x),x, will have the expected result. Note that this will fail in this case if TF1 does not contain a function and a name separated by a comma.
If the function argument is a procedure name, or an indexed procedure name, then it is used with the arguments as specified. For example, you can use:
Evaluate⁡function=evalfdig,Argument⁡TF1
to evaluate the field TF1 to floating point to the specified value of digits dig. Note that this method can be used to pass fixed values, determined at Maplet application creation time, to a local procedure using indexed function notation. As with the prior method, this approach also allows for a single Argument to contain multiple comma separated values. This form of evaluate is the only form that supports Argument using the value syntax, and allows passing of fixed values to the specified procedure.
If the function argument is not of either of the prior types, Evaluate dynamically creates an internal procedure unapplied with respect to all arguments specified by using references of type name. That is, the specified expression is computed by using the value(s) of the element(s) referenced by name. Argument elements cannot be used in the Evaluate element in this case. For example, if there are two text fields with references TF1 and TF2, use:
Evaluate⁡function=ⅆTF1ⅆTF2
to execute the command diff(TF1, TF2) in the underlying Maple session. Note that this form can be used with a local procedure, but all arguments must be single valued. The example where you pass a single field name to diff will not work if you specify the function as 'diff(TF1)'. For more information, see unapply.
If an argument is user-editable, for example, a text field, the user can enter an argument that is of the wrong type or does not parse correctly. It is recommended that type checking be used by calling a Maple procedure instead of directly calling the Maple function. By using the Get function, better error handling can be implemented. For arguments that can contain only appropriate values, for example, a check box, it is better to directly pass the value because it is safe and more efficient. For example, if there is a text field and a check box with references TF1 and UseCauchy, respectively, in the Maplet application definition, use:
Evaluate⁡function=myproc,Argument⁡UseCauchy
and write a procedure:
myproc := proc(UseCauchy)
expr := Maplets:-Tools:-Get( TF1::algebraic ); # expecting the text field to be an algebraic object
if UseCauchy then
int( expr, x, 'CauchyPrincipalValue' );
else
int( expr, x );
end if;
end proc;
`option` = symbol
The option of the target element to update. By default, the value option if it exists.
target = reference to an element (name or string)
A reference to the element to update with the result.
waitforresult = true or false
Whether the Maplet application waits for the Evaluate command result before running the remaining Maplet application commands in the same Action element. By default, the value is true.
with⁡MapletsElements:
maplet≔Maplet⁡Enter an expression,TextFieldTF1⁡width=30,Differentiate w.r.t. x:,Button⁡Do It,Evaluate⁡TF1=diff⁡TF1,x,Button⁡OK,Shutdown⁡TF1:
MapletsDisplay⁡maplet
The following three examples are identical except that the third has significantly better error handling:
mydiff1 := proc(f) diff(f, x); end proc:
maplet1≔Maplet⁡Enter an expression,TextFieldTF1⁡width=30,Differentiate w.r.t. x:,Button⁡Do It,Evaluate⁡TF1=mydiff1⁡TF1,Button⁡OK,Shutdown⁡TF1:
MapletsDisplay⁡maplet1
maplet2≔Maplet⁡Enter an expression,TextFieldTF1⁡width=30,Differentiate w.r.t. x:,Button⁡Do It,Evaluate⁡TF1=mydiff1,Argument⁡TF1,Button⁡OK,Shutdown⁡TF1:
MapletsDisplay⁡maplet2
mydiff3 := proc() f := Maplets[Tools][Get]('TF1'::algebraic); diff(f, x); end proc: maplet3 := Maplet([ ["Enter an expression", TextField['TF1']('width' = 30)], [ "Differentiate w.r.t. x:", Button("Do It", Evaluate('TF1' = "mydiff3", Argument('TF1'))), Button("OK", Shutdown(['TF1'])) ] ]): Maplets[Display](maplet3);
This is a duplicate of the first example, where the Argument element is used with value syntax:
maplet4≔Maplet⁡Enter an expression,TextFieldTF1⁡width=30,Differentiate w.r.t. x:,Button⁡Do It,Evaluate⁡target=TF1,function=diff,Argument⁡TF1,Argument⁡value=x,Button⁡OK,Shutdown⁡TF1:
MapletsDisplay⁡maplet4
See Also
Maplets/CommandElements
Maplets[Display]
Maplets[Elements][Action]
Maplets[Elements][Argument]
Maplets[Elements][Button]
Maplets[Elements][Maplet]
Maplets[Elements][SetOption]
Maplets[Elements][Shutdown]
Maplets[Elements][TextField]
Maplets[Tools][Get]
Maplets[Tools][Set]
name
Overview of Maplet Applications
string
unapply
Download Help Document