OPT_ARRAY

Previous  Next

 

OPT_ARRAY( pArray, default )

 


 

Retrieve an optional array pointer.  Return the default value if the parameter wasn't present.  The array can be passed directly or as a reference.  The macro will resolve any references.

 

The example is code from the GRAPH.AddElement function.

 

Example

 

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

//

// nElement = Graph.ADDELEMENT( control AS INTEGER,

//                              name    AS STRING,

//                              x-data  AS ARRAY,

//                              y-data  AS ARRAY ) AS INTEGER

//

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

//

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

  {

  AFX_MANAGE_STATE( AfxGetStaticModuleState() );

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

 

  BEGIN_PARSE( s, l )

     POP_INT( nControl )

     POP_STRING( pName )

     POP_ARRAY( pX )

     OPT_ARRAY( pY, NULL )

  END_PARSE

 

  mb_error_e nErr = SE_NO_ERR;

 

  int nElement = g_this->AddElement( nControl, pName, pX, pY, &nErr );

 

  if ( nElement == 0 )

     {

     RETURN_ERROR( nErr );

     }

  endif

 

  RETURN_INT( nElement );

  }

endfunc