  USER Library, ver. 1.2, Copyleft (l) Stanislav Sokolov, May 1998 onwards.

 ***************************************************************************
 * This library is subject to GNU General Library Public License ver. 2 of *
 * June 1991 and any later version. See COPYING.LIB for details.           *
 ***************************************************************************

A collection of useful console functions for C++ and QuickBASIC 4.5

This collection consists of two parts: QuickBASIC and C++

============================================================================
QuickBASIC part:
    USER.BAS
    USER.LIB
    USER.QLB
    USER.BI
    SAMPLES.BAS

Start QuickBASIC, using switch /l: qb /l user. USER.LIB & USER.QLB must be in
search path.

In your programs add line:
'$INCLUDE: 'USER.BI' for function definitions.

See SAMPLES.BAS for detailed information on how to use the functions.

USER.BAS is the source code for the library.


============================================================================
C++ part:
    USER.H
    BOX.CPP
    CENTRE.CPP
    CLF.CPP
    INTEXT.CPP
    RALIGN.CPP

Three functions have been converted to C++, and placed into three separate
files. RALIGN.CPP was added later, and is not found in QuickBASIC collection
If you wish to make use of the functions, #include the relative CPP file into 
your file or add it to your project.

Here is a short description of the functions (for more details see source
codes):


BOX.CPP
A box is defined as a class. Object Box can draw a box on the screen at 
specified coordinates, using single-line, double-line, thick, ASCII or 
user-defined border; inverse, normal, or none at all zooming; normal, 
transparant or none at all shadow; and placing an optional title centered 
on the top line of the box.

Several symbolic constants are defined to make box creation easier.

The main member function (Draw) accepts six parameters. the first four specify
the location and size of a box. The fifth and sixth parameters are optional.
They are a flag, which tells the object to save beckground before drawing a 
box (1 [on] by default), and a second optional parameter specifies a 
user-defined char to be used as border, if Style is set to B_NONE (the 
default is ' ').

Member function (Erase) restores the background, if it was saved and clears
a 'box-is-drawn' flag.

(Set...) member functions specify the outlook of the box.

(Draw) member function hides the cursor. If you wish to make cursor visible, 
make a call to _setcursortype(int), after calling box.Draw(...).

(Draw) and (Erase) member functions return 1 on success or 0 on failure.

Make a call to (Drawn) member function to find out if the object is in use -
only one box can be drawn per object.


CENTRE.CPP
Centres a string on a specified row. The first two parameters are Row and a
pointer to a string to be centered. The third and fourth parameters are
optional and are used to define a span, inside which the text will be 
centered.

In case of an error (e.g. text was longer than the screen line) the function 
returns 0, on success the x-location, where the centred text started is 
returned.

Hint: If you wish to find the x-location, without printing the text itself,
set Row parameter to 0. You can for example use this information when
centring a text in a file.


CLF.CPP
"Fancy CLS" (in QuickBASIC version the function is called CLR). The function
clears the screen in a fancy way, producing the effect of closing and
opening shutters. The two parameters specify foreground and background
colors the cleared screen shall have.

Unlike QuickBASIC CLR USER-function, clf(int, int) works correctly on any
resolution.

The function returns nothing.


INTEXT.CPP
A definition of a class with one public member function: InText(...)
It intends to replace C++'s cgets(), gets() and other functions of this
kind.

InText takes a pointer to a string buffer, which must be at least Length+1
bytes long; Length (the number of chars to accept); Y and X position, where
the text shall be printed; and Width (a one-line window, where the entered
text will be printed). If Width is smaller than Length, the text will be 
scrolled to sides, and out of vision.

The text can be edited at any location. Arrow keys, Home, End, BackSpace, 
Delete, and Ctrl-Delete (delete to the end-of-line) can be used.

The function features a two-way pointer list.

On success the address of buffer is returned; on error or if the user pressed
'Esc' NULL is returned.


RALIGN.CPP
Right aligns a string on a specified row. The first two parameters are Row 
and a pointer to a string to be aligned. The third parameter is optional and 
is used to define a right boundary, alongside which the text will be aligned.

In case of an error (e.g. text was longer than the screen line) the function 
returns 0, on success the x-location, where the aligned text started is 
returned.

Hint: If you wish to find the x-location, without printing the text itself,
set Row parameter to 0. You can for example use this information when right
aligning a text in a file.



I had to make use of in-line assembler in all the functions, for some video
functionalities were not to be found in standard libraries.


All CPP files contain a commented out main() function with a sample use
of the respective functions. Remove the comments and run the program to
view a sample.


============================================================================
Contact the author by e-mail:
stanislavs@hotmail.com

Internet:
http://members.tripod.com/~stanislavs/prog/prog.htm
