mb_get_exit_code

Previous  Next

 

mb_value_t mb_get_exit_code( mb_interpreter_t* s )

 


 

Returns the current exit code from the interpreter.  The exit code is the result from one of the Run or Spawn functions.  It is set by either END [exit code] or STOP [exit code].

 

Example

 

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

//

int CScriptFrame::WINDOW_Run( HWND hWindow, LPCTSTR lpszScriptFile, mb_value_t* pExitCode )

  {

  int nStatus = SE_RN_BAD_PARAMS;

 

  if ( ::IsWindow( hWindow ) && lpszScriptFile )

     {

     nStatus = ::SendMessage( hWindow,

                              WM_RUNSCRIPT,

                              (WPARAM)lpszScriptFile,

                              MAKELONG( MAKEWORD( TRUE, 0 ),

                                        MAKEWORD( 0, eNoErrMsg ) ) );

 

     // Return error code from RunScript if needed

 

     if ( nStatus == SE_PS_INCORRECT_CONTEXT )

        {

        nStatus = m_nInvalidContext;

        }

     endif

 

     if ( pExitCode )

        {

        const mb_value_t vDefault = { MB_DT_INT, NULL, 0 };

 

        *pExitCode = vDefault;

 

        LPINTERP pBas = (LPINTERP)::SendMessage( hWindow, WM_GETINTERP, 0, 0 );

 

        if ( pBas )

           {

           // Get the exit code from the Script

 

           *pExitCode = mb_get_exit_code( pBas );

           }

        endif

 

        if ( ( pExitCode->type == MB_DT_NIL ) || ( pExitCode->type == MB_DT_UNKNOWN ) )

           {

           *pExitCode = vDefault;

           }

        endif

        }

     endif

     }

  endif

 

  return nStatus;

  }

endfunc