mb_pop_type

Previous  Next

 

status_t mb_pop_type( mb_interpreter_t* s, void** l, mb_data_e* type )

 


 

This function pops a parameter that is a data type from the interpreter.  Valid data types are

 

INTEGER

STRING

REAL

HANDLE

REFERENCE

MODULE

ARRAY

 

The type is returned as mb_data_e.

 

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

// mb_value_t structure

//

typedef enum mb_data_e

  {

  MB_DT_NIL            = -1, // Invalid or no type

  MB_DT_UNKNOWN        = 0,  // Undefined type

  MB_DT_ANY            = 0,  // Any Type

  MB_DT_INT            = 1,  // Integer

  MB_DT_REAL           = 2,  // Floating point

  MB_DT_STRING         = 3,  // String

  MB_DT_REFERENCE      = 4,  // Reference pointer

  MB_DT_MODULE         = 5,  // Core, std or extension function

  MB_DT_HANDLE         = 6,  // Array, integer, real or string

  MB_DT_ARRAY          = 7   // Variable

  } mb_data_e;

 

Example

 

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

  {

  AFX_MANAGE_STATE( AfxGetStaticModuleState() );

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

 

  char*       pName;

  mb_data_e   type;

  mb_value_t  val;

  int         nHandle = 0;

  int         nInitialSize = 0;

 

  CMyBASIC2_List* pList = new CMyBASIC2_List;

 

  mb_check( mb_attempt_open_bracket( s, l ) );

 

  // Must have at least 1 entry

 

  mb_check( mb_pop_string( s, l, &pName ) );

  mb_check( mb_pop_type( s, l, &type ) );

 

  if ( pList->AddItem( pName, type ) < 1 )

     {

     mb_set_error( s, l, SE_RN_OUT_OF_MEMORY );

     mb_check( mb_push_handle( s, l, NULL ) );

 

     return MB_FUNC_ERR;

     }

  endif

  .

  .

  .