OMget_array_size and OMset_array_size


Synopsis


int  OMget_array_size (
OMobj_id  object_id,
int  *size  );

int  OMXobj::get_array_size (
int  *size  );

int  OMset_array_size (
OMobj_id  object_id,
int  size  );

Description

These routines get and set the size of the specified array object.

OMset_array_size is suitable only for one-dimensional arrays. To set the dimensions of multi-dimensional arrays, define the dimensions of your object in terms of integer AVS/Express objects and set the values of these objects directly.

Arguments

object_id

The id of an array object.

size

In OMget_array_size, an output argument containing the array size. For a multi-dimensional array, OMget_array_size returns the product of the sizes in each dimension.

In OMset_array_size, an input argument specifying the new array size.

Returned value

The status code (see Return Status ).

Example

Assume you have integer array objects defined as follows in the V code:


int mdims = 100, ndims = 200;
int my_array1[mdims][ndims];
int my_array2[mdims];

my_array1 is a multidimensional array, so you cannot set its size with this routine. To get the values of each dimension independently, use: See OMget_array_dims . To set the values of each dimension independently, you set the values of the mdims and ndims objects using OMset_int_val.

my_array2 is one-dimensional, so you can get and set its size with these routines. In the code below, assume that parent_id contains the id of the arrays' parent object:


OMobj_id parent_id, my_array1, my_array2;
int size;
int dim_sizes[OM_ARRAY_MAXDIM];
...
my_array1 = OMfind_subobj(parent_id,
OMstr_to_name("my_array1"),
OM_OBJ_RD);
my_array2 = OMfind_subobj(parent_id,
OMstr_to_name("my_array2"),
OM_OBJ_RW);
status = OMget_array_size(my_array1, &size);
printf("Array size: %d", size) /* Prints 20000. */
status = OMget_array_size(my_array2, &size);
printf("Array size: %d", size) /* Prints 100. */
status = OMset_array_size(my_array2, 300);