mb_get_array_dimensions

Previous  Next

 

C Syntax

int mb_get_array_dimensions( LPARRAY pArr, int* ix_array = NULL )

 

C++ Syntax

int mb_get_array_dimensions( LPARRAY pArr, int* ix_array )

 


 

This will copy the array dimensions into the ix_array.  The size of the ix_array must be at least MB_MAX_DIMENSION_COUNT. The array is filled in with the dimensions with the right-most dimension in lowest index.  For example;

 

DIM arr(1,2,3,4) AS INTEGER

 

would return an ix_array as:

 

ix_array[0] = 4

ix_array[1] = 3

ix_array[2] = 2

ix_array[3] = 1

 

The function returns the dimension count.  The ix_array can be omitted or set to NULL if you only need the dimension count.

 

Example

 

/////////////////////////////////////////////////////////////////////////////

// Return the total number of items in array

//

int _item_count( mb_interpreter_t* s, void** l )

{

  // Parse Parameter

  BEGIN_PARSE( s, l )

     POP_ARRAY( pArr )

  END_PARSE

 

  int ix_array[MB_MAX_DIMENSIONS];

 

  memset( ix_array, 0, sizeof( ix_array ) );

  mb_get_array_dimensions( pArr, ix_array );

 

  int nCount = 0;

 

  for ( int i = 0; i < MB_MAX_DIMENSIONS; i++ )

  {

     nCount += ix_array[i];

  }

 

  // Return Count as INTEGER

  RETURN_INT( nCount );

}