CONSOLE Object
Updated: Nov 7, 2005

The CONSOLE interface includes:

1. Console statements CLS, COLOR, INPUT, LOCATE, PAUSE, PRINT, SETCONSOLEMODE,
   SETCONSOLETITLE, SHOWCONSOLE and FREECONSOLE

2. String Functions GET$, INKEY$ and INPUT$

3. Numeric Functions CRSLIN, ISCONSOLE, POS and SCREEN

4. a CONSOLE object described below 

Console Object functions all return integer values and may be listed in three
categories:  general, keyboard and mouse.


PROPERTIES (Read Only Numeric):
~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~
ErrorHandle
           Standard error handle

Event      Presence (True) or absence (False) of user input event

  SELECT CASE Console.Event
    CASE 0: PRINT "Maybe user passed out"
    CASE 1: PRINT "Keyboard input!"
    CASE 2: PRINT "Mouse input!"
    CASE 4: PRINT "Window buffer size event!"
    CASE 8: PRINT "Menu event!"
    CASE 16: PRINT "Focus event!"
  END SELECT

  Note: .Event stores information on one event each time it is called.  Thus,
  the data obtained with the Keyboard and Mouse functions below applies to the
  particular .Event call.  If an .Event call returns 0, no further event has
  occurred, but the values of the Keyboard and Mouse functions still reflect
  the last events captured respectively.

  i=Console.Event 'is not blocking; i = 0 if no event yet
  Please see example code below.

Height     Screen height in character rows

InputHandle
           Standard input handle

KeyState   Asynchronous key state.  MyVar = CONSOLE.KeyState(vkey)
           where vkey is a virtual key code.

  Note: CONSOLE.KeyState() > 0 indicates the key was pressed since the last
  call, < 0 indicates the key is presently pressed and <> 0 means either.
  Virtual key codes for physical mouse buttons may be used and SCREEN.MouseSwap
  indicates if logical mouse buttons are swapped.

OutputHandle
           Standard output handle

MaxHeight  Maximum screen height given current buffer, font, and screen

MaxWidth   Maximum screen width given current buffer, font, and screen

Width      Screen width in character columns


KEYBOARD   Description
~~~~~~~~   ~~~~~~~~~~~
Char       ASCII character

CtrlKeys   Control keys status in form of bit mask

KeyDown    A key was pressed

KeyCode    Virtual key code

LeftAlt    Left alt key pressed

LeftCtrl   Left ctrl key pressed

RepeatCount
           Repeat count for pressed key

RightAlt   Right alt key pressed

RightCtrl  Right ctrl key pressed

ScanCode   Virtual scan code

Shift      Shift key pressed

The mouse events work on a W98 machine with or without a DOS mouse driver
installed (mouse.sys in config.sys or mouse.com in autoexec.bat).  Thus far,
mouse events have not been captured on a W2K machine.


MOUSE      Description
~~~~~      ~~~~~~~~~~~
Buttons    Buttons pressed in form of a bit mask
           1 = left button; 2 = right button; etc

MouseX     Mouse position column 0 to .Width - 1

MouseY     Mouse position row 0 to .Height - 1

CtrlMouse  Control keys status in form of bit mask
           Similar to .CtrlKeys, except reported in a mouse event

DoubleClick
           True (not 0) if double click

MouseMoved True (not 0) if mouse moved


METHODS    Arguments & Comments
~~~~~~~    ~~~~~~~~~~~~~~~~~~~~
Cursor     Sets cursor visibility and size 1 - 100%

  CONSOLE.Cursor = 0   'now cursor invisible
  CONSOLE.Cursor = 1   'minimum visible cursor
  CONSOLE.Cursor = 100 'maximum visible cursor


###########
If "event-oriented" code is desired, the TIMER object could be used perhaps in
repeat mode to call a keyboard and mouse event procedure. 

Use AND logic to detect any configuration of .CtrlKeys and .CtrlMouse.


###########
Please see hotcon.bas in the HotTrial download for an example and tutorial on
CONSOLE coding.


Copyright 2003-2005 James J Keene PhD
Original Publication: Oct 24, 2003
