User-friendly access to embedded components
algebraic ; expression to evaluate using component values
name ; variable in which to store the retrieved value
name ; target component to store results
expression of the form refresh = value, where value is true or false; specifies whether or not to immediately update the document
The Do command evaluates its argument using values retrieved from specified embedded components.
Optionally, the result can be stored into an embedded component
A naming convention is used to access component values.The expression %name refers to the component named name
By default, the attribute that will be queried or set is value, except for MathExpressionComponent for which the attribute that will be queried or set is expression. Alternate attributes can be specified using %name(attr)
After retrieving an attribute of a component, the result will be parsed and must be a valid Maple expression. To avoid parsing, refer to the component using %%name. Note that parsing of the value attribute of a MathExpressionComponent will result in an error (the expression attribute should be used instead).
After parsing, a type-check can be automatically applied by specifying the type using %name::type or %name(attr)::type. An error will be generated if the expression is not of the given type.
The result of querying component attributes can optionally be stored in a variable or in another component.
To store the value in a variable, use Do(myvar= ... %ComponentName ...).
To store the value in another component, use Do(%Comp1 = ... %Comp2 ...).
Note: Some embedded components, like Label, do not have a value attribute. To retrieve or set attributes on such components, an explicit attribute needs to be specified, e.g. %MyLabel(caption).
By default, when this command is invoked from inside the code which is executed as the action of another embedded component, the document is not updated until that code terminates. The option refresh = true (or just refresh) can be used to force the document to update during the call to Do.
Insert a Math Expression component and two Text Area components from the Components palette. Change the name of each component to expression, from, and to respectively by editing the Name field in the component properties. To view and edit component properties, select a component, and then make the changes to the component properties shown in the Context Panel. Now, enter an expression into the Math Expression component and integers into the two Text Area components accordingly.
Insert three Math Expression components called ResultField, InputField1, and InputField2. Enter expressions into the InputFields.
Do(%ResultField = 2*%InputField1+%InputField2);
Insert two Math Expression components, and enter an integer into the first, called PrecisionField, and an expression which evaluates to a floating point value in the second, called Input.
Do(q = evalf[%PrecisionField::integer]( %Input ));
Insert a Button component called MyButton, and two Text Area components, called TF and MF. Enter numbers into both of the Text Area components.
Do(%MyButton(caption) = %TF(value)*%MF+1);
Insert two Plot components called Plot1 and Plot2.
Do(%Plot2 = %Plot1 );
This example shows a math container being updated at two second intervals, using the refresh option.
R := Statistics:-Sample(Statistics:-RandomVariable(Normal(0,1)),4);
for i from 1 to 4 do
DocumentTools:-Do(%MathContainer=R[i], 'refresh'=true );
while time[real]()-st < 2 do end do;
Download Help Document
What kind of issue would you like to report? (Optional)