SetProperty - Maple Help

# Online Help

###### All Products    Maple    MapleSim

DocumentTools

 SetProperty
 set property of an embedded component

 Calling Sequence SetProperty(id, attr, val, refreshopt) SetProperty([id1, attr1, val1], [id2,attr2,val2], ... , refreshopt)

Parameters

 id - {name, string} ; name of embedded component attr - {name, string} ; property of the component that is to be set val - (optional) anything ; value of property to set refreshopt - expression of the form refresh = value, where value is true or false; specifies whether or not to immediately update the document

Description

 • The SetProperty function sets the value of a property of an embedded component.
 • If the val option is omitted, the referenced component is reset to its default value.
 • 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 SetProperty.
 • For a list of embedded components, see Overview of Embedded Components.

Examples

Suppose that your document has a slider component with the name Slider1. To set the position of this slider to $\frac{1}{10}$th of its maximum (assuming the range is the default of 0..100) , you can do this:

 > $\mathrm{with}\left(\mathrm{DocumentTools}\right):$
 > $\mathrm{SetProperty}\left('\mathrm{Slider1}','\mathrm{value}',10\right)$

Suppose your document has a plot component with the name Plot0. To display a single plot in the component, use the following commands.

 > $\mathrm{p1}≔\mathrm{plot}\left(x,x=0..1\right):$
 > $\mathrm{SetProperty}\left(\mathrm{Plot0},\mathrm{value},\mathrm{p1}\right):$

To display an array of plots in the plot component, you must force the array to stay unsimplified by referring to it with quotes.  See the specific component help page for any other special input instructions.

 > $\mathrm{p2}≔\mathrm{plot}\left({x}^{2},x=0..1\right):$
 > $\mathrm{p3}≔\mathrm{plots}\left[\mathrm{display}\right]\left(\mathrm{Array}\left(\left[\mathrm{p1},\mathrm{p2}\right]\right)\right):$
 > $\mathrm{SetProperty}\left(\mathrm{Plot0},\mathrm{value},"p3"\right):$

If code attached to a button causes several other embedded component values to change, you would normally not want the document to update until all those changes have been made.  If you want to force updating after each change, use the refresh = true option (which can be abbreviated as just refresh).  For example the following code illustrates updating a series of ComboBox elements.  It is assumed that this code is attached to a Button component.

 > $s≔\left[\right]:$
 > $\mathbf{use}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{DocumentTools}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{for}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}i\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{to}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}5\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}s≔\left[\mathrm{op}\left(s\right),i\right];\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{SetProperty}\left(\mathrm{ComboBox}||i,'\mathrm{itemList}',s\right);\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathrm{SetProperty}\left(\mathrm{ComboBox}||i,'\mathrm{value}',{s}_{1},\mathrm{refresh}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end do}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{end use}$

Compatibility

 • The DocumentTools[SetProperty] command was updated in Maple 2016.

 See Also