Console

Previous  Next

 

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]

 

These statements allows your BASIC program to customize the output screen.  If you haven't defined a console handler, MyBASIC2 will signal an error when they're used.

 


Console Structures

 

typedef struct mb_console_screen_t

  {

  int                  mode;

  int                  xpos;

  int                  ypos;

  int                  width;

  int                  height;

  } mb_console_screen_t;

 

typedef struct mb_console_color_t

  {

  uint_t               bg;

  uint_t               fg;

  } mb_console_color_t;

 

typedef struct mb_console_font_t

  {

  char*                name;

  int                  size;

  int                  bold;

  int                  italic;

  } mb_console_font_t;

 


Console 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;

}