...
Code Block | ||
---|---|---|
| ||
objarray set <obj> {<value_1> ... <value_n>}|<index> <value> | -binary <data> |
objarray set <obj> <index> <value>
Set the value of the item $index (from 0 to n-1) with the value $value, or all values from a list {value_1 ... value_n}.
The value could be the special string “NaN” (not a number) or “Inf” (infinite)
<value> could be a single number or a list of multiple numbers (to set the values of index, index+1, …)
To set some index the array space must be allocated previously with a size greater of the index.
...
objarray
...
set
...
<obj>
...
{<value_1>
...
...
...
<value_n>
...
}
Set all values from a list {value_1 ... value_n}.
In fact instead the list could be another objarray of the same length (can be of other type, a casting will be done for each item).
objarray set <obj> -binary <data>
copy directly the bytes of <data>, for example to store the data of an image.
e.g.
Code Block | ||
---|---|---|
| ||
set obj [objarray new intarray 3 0] # -> 0 0 0 objarray set $obj {6 3 8} # -> 6 3 8 # in floating point arrays, 'nan' values are also allowed set oa [ objarray new doublearray 4 nan] # --> NaN(7ffffffffffff) NaN(7ffffffffffff) NaN(7ffffffffffff) NaN(7ffffffffffff) objarray set $oa 0 0.123 # --> 0.123 NaN(7ffffffffffff) NaN(7ffffffffffff) NaN(7ffffffffffff) objarray set $oa 0 nan # --> NaN(7ffffffffffff) NaN(7ffffffffffff) NaN(7ffffffffffff) NaN(7ffffffffffff) objarray set $oa 0 {0 1 2} # --> 0 1 2 NaN(7ffffffffffff) set oa [ objarray new_from_to intarray 1 10] # --> 1 2 3 4 5 6 7 8 9 10 set obj [objarray new intarray -values {5 6 7 8}] # --> 5 6 7 8 objarray set $oa -binary [objarray get_binary $obj]] # --> 5 6 7 8 set oa [ objarray new_from_to doublearray 1 10] # --> 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 objarray set $oa -binary [objarray get_binary $obj]] # --> 1.27319747483e-313 1.6975966331e-313 |