mb_check_array_dimensions

Previous  Next

 

C Syntax

bool_t mb_check_array_dimensions( LPARRAY pArr, mb_data_e eType, int ix1, int ix2, int ix3, int ix4 )

 

C++ Syntax

bool_t mb_check_array_dimensions( LPARRAY pArr, mb_data_e eType, int ix1, int ix2 = 0, int ix3 = 0, int ix4 = 0 )

 


 

Checks array dimensions and array type.  To check for any array type, pass MB_DT_ANY as type.  The following macros can be used for dimension comparison on each dimension;

 

MB_EXACTLY( x )    Match dimension exactly

MB_AT_LEAST( x )   Specified array dimension must have at least this size

MB_MAX_DIM( x )    This is the maximum size of specified dimension

MB_GT( x )         Dimension must be Greater Than specified dimension size.

                  This is mainly used to ensure array index is within bounds

 

Example

 

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

// Returns TRUE if array is large enough for specified dimensions

//

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

{

  // Parse Parameter

  BEGIN_PARSE( s, l )

     POP_ARRAY( pArr )

     POP_INT( ix1 )

     OPT_INT( ix2, 0 )

     OPT_INT( ix3, 0 )

     OPT_INT( ix4, 0 )

  END_PARSE

 

  bool_t bResult = mb_check_array_dimensions( pArr,

                                              mb_get_array_type( pArr ),

                                              MB_AT_LEAST( ix1 ),

                                              MB_AT_LEAST( ix2 ),

                                              MB_AT_LEAST( ix3 ),

                                              MB_AT_LEAST( ix4 ) );

 

  // Return the type as string

  RETURN_INT( bResult );

}