11.46 setvector()
This function may be used to modify vector attributes (predefined or user-defined). It is possible to assign new values to the attribute as a whole or to only a continuous portion of it.
Definition
boolean setvector ( object Object input, attribute Attribute input, vector NewValue input { , anyvalue FirstIndex input { , anyvalue LastIndex input } } { , boolean SendEvent := true input } )
Parameters
- object Object input
- This parameter defines the object whose attribute values shall be modified.
- attribute Attribute input
- This parameter defines the attribute to be set.
- vector Value input
- This parameter specifies the value list that will be assigned to the vector attribute.
- anyvalue FirstIndex input
- This optional parameter defines the start index as of which the element values are modified. For one-dimensional array attributes an integer value should be specified, for two-dimensional arrays an index value. The default value for one-dimensional array attributes is the integer value 1, for two-dimensional arrays the index value [1,1].
- anyvalue LastIndex input
-
This optional parameter specifies the end index up to which the values of the attribute are are modified through the values from the value list. Again, an integer value is expected for one-dimensional array attributes and an index value for two-dimensional arrays. The LastIndex value should be after the FirstIndex value.
If no LastIndex parameter is specified (default value nothing), the size of the Value vector defines the number up to which the vector attribute is modified. The subsequent element values of the attribute are then truncated.
- boolean SendEvent := true input
- This optional parameter controls whether setting the attribute should trigger an attribute-changed event. The default value is true, which causes the changed event to be sent for the attribute. If the parameter value is false, no event is sent.
Return value
- true
- Attribute has been modified.
- false
- Modification of the attribute could not be completed.
Fault behavior
The function call fails for an invalid object or attribute, for an invalid index range or if setting is not possible e.g. due to a mismatch between attribute type and value type.
Example
dialog D window Wi { .title "Cities"; .width 300; tablefield TfCities { .xauto 0; .yauto 0; .rowheight[0] 25; .colwidth[0] 80; .rowcount 1; .colcount 2; .rowheader 1; .direction 2; } on close { exit(); } } on dialog start { variable hash Capitals := [ "germany" => "berlin", "france" => "paris", "england" => "london" ]; // fill the title row setvector(TfCities, .content, ["Country", "City"]); // fill the country and city column setvector(TfCities, .field, keys(Capitals), [1,1], [itemcount(Capitals),1]); setvector(TfCities, .field, values(Capitals), [1,2]); }
See also
C