Do - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


DocumentTools

  

Do

  

user-friendly access to embedded components

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Do(expr)

Do(var=expr)

Do(target=expr, refreshopt)

Parameters

expr

-

algebraic ; expression to evaluate using component values

var

-

name ; variable in which to store the retrieved value

target

-

name ; target component to store results

refreshopt

-

expression of the form refresh = value, where value is true or false; specifies whether or not to immediately update the document

Description

• 

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.

Examples

withDocumentTools

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.

Doint%expression,x=%from::integer..%to::integer

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.

Doq=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%MyButtoncaption=%TFvalue%MF+1

Insert two Plot components called Plot1 and Plot2.

Do%Plot1=plotx2,x=0..1

Do%Plot2=%Plot1

This example shows a math container being updated at two second intervals, using the refresh option.

RStatistics:-SampleStatistics:-RandomVariableNormal0&comma;1&comma;4&semi;forito4doDocumentTools:-Do%MathContainer=Ri&comma;refresh=true;sttimereal;whiletimerealst<2doenddoenddo&colon;

See Also

DocumentTools

MathExpressionComponent

TextAreaComponent