Difference between revisions of "SetValue Command"

From GeoGebra Manual
Jump to: navigation, search
m
(;SetValue( <Dependent Object>, ? ) :This is a special syntax that will set a dependent object to undefined without needing to fully redefine it using <code>=</code>.)
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|scripting}}
 
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|scripting}}
;SetValue[ <Boolean>, <0|1> ]
+
;SetValue( <Boolean>, <0|1> )
 
:Sets the state of a boolean / check box : 1 = true, 0 = false
 
:Sets the state of a boolean / check box : 1 = true, 0 = false
:{{example|1=If  ''b'' is a boolean, <code> SetValue[b,1]</code> sets the boolean ''b'' as ''true''.}}
+
:{{example|1=If  ''b'' is a boolean, <code> SetValue(b,1)</code> sets the boolean ''b'' as ''true''.}}
  
;SetValue[ <Object>, <Object> ]
+
;SetValue( <Object>, <Object> )
 
:Let''A'' be the first and ''B'' the second object. If ''A'' is a [[Free, Dependent and Auxiliary Objects|free object]] or a [[Points and Vectors|Point]] restricted to [[Geometric Objects#Paths|Path or Region]], its value is set to current value of ''B'' (i.e. ''A'' doesn't change value if ''B'' is changed afterwards).
 
:Let''A'' be the first and ''B'' the second object. If ''A'' is a [[Free, Dependent and Auxiliary Objects|free object]] or a [[Points and Vectors|Point]] restricted to [[Geometric Objects#Paths|Path or Region]], its value is set to current value of ''B'' (i.e. ''A'' doesn't change value if ''B'' is changed afterwards).
:{{example|1=If  ''f'' is a function, <code>SetValue[f, RandomElement[{cos(x), 3x+2, ln(x)}]]</code> defines, at random, f as being one of the functions proposed in the list.}}
+
:{{example|1=If  ''f'' is a function, <code>SetValue(f, RandomElement({cos(x), 3x+2, ln(x)}))</code> defines, at random, f as being one of the functions proposed in the list.}}
  
 +
;SetValue( &lt;List>, <Number>, <Object> )
 +
:Let ''n'' be the ''<Number>''. The command SetValue sets the n-th element of a free list to the current value of the object. Number ''n'' can be at most 1 + length of L.
  
;SetValue[ <List>, <Number>, <Object> ]
+
;SetValue( &lt;Dependent Object>, ? )
:Let ''n'' be the ''<Number>''. The command SetValue sets the n-th element of a free list to the current value of the object. Number ''n'' can be at most 1 + length of L.
+
:This is a special syntax that will set a dependent object to undefined without needing to fully redefine it using <code>=</code>.
 +
 
 +
;SetValue( <[[Action_Objects#Drop-down lists|drop-down list]]>, <Number n > ) : Set  ''n'' as [[SelectedIndex_Command| the index of the selected element]] in the drop-down list.

Revision as of 10:13, 10 January 2022


SetValue( <Boolean>, <0|1> )
Sets the state of a boolean / check box : 1 = true, 0 = false
Example: If b is a boolean, SetValue(b,1) sets the boolean b as true.


SetValue( <Object>, <Object> )
LetA be the first and B the second object. If A is a free object or a Point restricted to Path or Region, its value is set to current value of B (i.e. A doesn't change value if B is changed afterwards).
Example: If f is a function, SetValue(f, RandomElement({cos(x), 3x+2, ln(x)})) defines, at random, f as being one of the functions proposed in the list.


SetValue( <List>, <Number>, <Object> )
Let n be the <Number>. The command SetValue sets the n-th element of a free list to the current value of the object. Number n can be at most 1 + length of L.
SetValue( <Dependent Object>, ? )
This is a special syntax that will set a dependent object to undefined without needing to fully redefine it using =.
SetValue( <drop-down list>, <Number n > )
Set n as the index of the selected element in the drop-down list.

Comments

SetValue in scripting[edit]

If you want to change value of an object in Scripting, always use SetValue rather than =. See Responsive Applets for more information.

© 2024 International GeoGebra Institute