mb_set_console_handler

Previous  Next

 

status_t mb_set_console_handler( mb_interpreter_t* s, mb_console_func_t pHandler )

 


 

Sets the current console handler.  To remove the handler, supply NULL.  The format of the console handler is defined as

 

typedef int (*mb_console_func_t)( struct mb_interpreter_t*, int cmd, void* pParams );

 

The following MyBASIC2 statements uses the Console handler

 

CLS

COLOR background [, foreground]

FONT name, size, bold, italic

SCREEN mode, [x-pos], [y-pos], [width], [height]

 

See the Console chapter for more information about the console handler

 

Example

 

int _console( mb_interpreter_t* s, int cmd, void* pParams );

 

mb_set_console_handler( bas, _console );

 

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

//

int _console( mb_interpreter_t* s, int nCmd, void* pParams )

{

  switch ( nCmd )

  {

     case MB_CONSOLE_CLS:

        // Call function to handle CLS

        return ConsoleCls();

     case MB_CONSOLE_SCREEN:

        // Call function to handle SCREEN

        return ConsoleScreen( (mb_console_screen_t*)pParams );

     case MB_CONSOLE_COLOR:

        // Call function to handle COLOR

        return ConsoleColor( (mb_console_color_t*)pParams );

     case MB_CONSOLE_FONT:

        // Call function to handle FONT

        return ConsoleFont( (mb_console_font_t*)pParams );

  }

  return MB_FUNC_ERR;

}