RETURN_VALUE

Previous  Next

 

RETURN_VALUE( value )

 


 

Returns a variable of type mb_value_t.

 

The mb_value_t type is similar to the OLE data type VARIANT.  It contains a tag with the type, the name of the variable and the value of the variable.

 

Example

 

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

//

// return = LIST.Max( lid          AS HANDLE,

//                    itx          AS INTEGER, [=0]

//                    return-value AS INTEGER [=FALSE] ) AS VARIANT

//

// return = LIST.Max( lid          AS HANDLE,

//                    item         AS STRING,

//                    return-value AS INTEGER [=FALSE] ) AS VARIANT

//

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

//

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

  {

  AFX_MANAGE_STATE( AfxGetStaticModuleState() );

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

 

  int         itx   = 0;

 

  BEGIN_PARSE( s, l )

     POP_HANDLE( hLid )

     POP_VALUE( vItem )

     OPT_INT( bReturnValue, FALSE )

  END_PARSE

 

  CMyBASIC2_List* pList = (CMyBASIC2_List*)GetHandle( theApp.GetHandles(), int( hLid ) );

 

  if ( !pList )

     {

     RETURN_ERROR( SE_RN_BAD_HANDLE );

     }

  endif

 

  if ( vItem.type == MB_DT_STRING )

     {

     // Get ITX

 

     itx = pList->GetITX( vItem.value.string );

     }

  else if ( vItem.type == MB_DT_INT )

     {

     itx = vItem.value.integer - mb_get_base( s );

     }

  else if ( vItem.type == MB_DT_REAL )

     {

     itx = int( vItem.value.float_point ) - mb_get_base( s );

     }

  else

     {

     RETURN_ERROR( SE_RN_INVALID_DATA_TYPE );

     }

  endif

 

  RETURN_VALUE( pList->Max( itx, bReturnValue ) );

  }

endfunc