Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

<type>: chararray shortarray intarray longarray longlongarray floatarray doublearray

objarray new <type> -values {<value_1> ... <value_n>}

<value_i> must be numeric values compatible with the <type>

In fact is is possible to provide another other objarray instead the list of values to copy its values. It can be of other type, a casting will be applied to convert each value to the destination type.

objarray new <type> <size> ?<fill_value>?

<size>: integer > 0 to create an array of this size. If <fill_value> is provided the array items are set to this value.

objarray new <type> -binary <data>

<data> is an arbitrary array of bytes (unsigned char), e.g. to store data of an image.

e.g.

Code Block
set obj [objarray new intarray 3] 
-> 1518360 1518610 0 (3 random unitialized values) 
set obj [objarray new intarray 5 1] 
-> 1 1 1 1 1 (5 values intialized to 1) 
set obj [objarray new intarray -values {6 3 8}] 
-> 6 3 8 
set obj [objarray new intarray -binary [binary decode base64 AQAAAAIAAAADAAAABAAAAA==]] 
-> 1 2 3 4 
set obj2 [objarray new intarray -binary [objarray get_binary $obj]] 
-> 1 2 3 4