POP_HANDLE

Previous  Next

 

POP_HANDLE( handle )

 


 

Retrieves a HANDLE parameter.  If not present, an error will be signalled.

 

This example is from the code from PROFILE.Read

 

Example

 

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

// result = PROFILE.Read( hHandle   AS HANDLE,

//                        key       AS STRING,

//                        valuename AS STRING,

//                        default   AS VARIANT ) AS VARIANT

//

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

  {

  AFX_MANAGE_STATE( AfxGetStaticModuleState() );

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

 

  mb_value_t  value       = MB_EMPTY_VALUE;

 

  BEGIN_PARSE( s, l )

     POP_HANDLE( hHandle )

     POP_STRING( lpSection )

     POP_STRING( lpEntry )

     OPT_VALUE( defval, MB_EMPTY_VALUE )

  END_PARSE

 

  CXMLProfile* pProfile = (CXMLProfile*)GetHandle( g_arrProfiles, (int)hHandle );

 

  if ( pProfile )

     {

     CString strDefault;

 

     if ( defval.type == MB_DT_INT )

        {

        strDefault.Format( "%d", defval.value.integer );

        }

     else if ( defval.type == MB_DT_REAL )

        {

        strDefault.Format( "%f", defval.value.float_point );

        }

     else if ( defval.type == MB_DT_STRING )

        {

        strDefault.Format( "%s", defval.value.string );

        }

     else

        {

        RETURN_ERROR( SE_RN_INVALID_ARGUMENT );

        }

     endif

 

     CString str = pProfile->GetProfileString( lpSection, lpEntry, strDefault );

     String2Value( str, value );

     }

  else

     {

     RETURN_ERROR( SE_RN_BAD_HANDLE );

     }

  endif

 

  mb_check( mb_push_value( s, l, value ) );

 

  return MB_FUNC_OK;

  }

endfunc