Dec 082017
MSC Color rtns. | |||
---|---|---|---|
File Name | File Size | Zip Size | Zip Type |
COLOR.C | 10890 | 1701 | deflated |
COLOR.DOC | 13679 | 2324 | deflated |
COLOR.H | 1061 | 328 | deflated |
COLOR.LIB | 5135 | 2288 | deflated |
Download File MSC_COLR.ZIP Here
Contents of the COLOR.DOC file
COLOR FOR MICROSOFT C
INTRODUCTION
These routines were written using Microsoft C version 5.00 to
implement color input/output on the IBM (or compatible) color
graphics adapter. The routines make use of the graphics routines
in the newer version of Microsoft C. This version of color
implementation is preferable to my previous version which
required calls to interrupt procedures. All required function
declarations, include statements, and global variable definitions
are contained in the color.h file.
Feel free to use these routines whenever and wherever. If you have
any comments, corrections, or suggestions, contact me here under
user-id 75216.2063.
ANDY ECKHARDT
USE OF COLOR ROUTINES
Using the file placement scheme recommended by Microsoft, the
files required for linking in these routines should be placed as
follows:
File Library
color.h \include
color.lib \lib
Linking these routines is accomplished with the following
command:
cl yourpgm /link color
__________________________________________________________________
COLOR ROUTINES
__________________________________________________________________
void bell()
This routine sounds the speaker momentarily. It is used to
signal an obvious error in I/O.
NOTES:
The variable high_val can be altered to create different
pitches and the length of the sound can be changed by altering
the loop ending count.
EXAMPLE:
#include
main()
{
bell();
}
__________________________________________________________________
void clreol()
This routine clears the screen from the current cursor
position to the end of the line and returns the cursor to its
beginning position.
EXAMPLE:
#include
main()
{
clreol();
}
__________________________________________________________________
void col_gchar(char_in)
char *char_in
This routine gets a character from the console. The
character is displayed in the default foreground and background
colors.
NOTES:
The character values entered are edited to exclude non-
displayable characters, control characters, alternate characters,
and extended keyboard characters (F1, F2, etc.).
EXAMPLE:
include
main()
{
char char_in;
col_gchar(&char_in);
}
__________________________________________________________________
void col_gdouble(double_in, max_length)
double *double_in;
int max_length;
This routine gets a double value from the console and
displays it in the default foreground and background colors.
NOTES:
The max_length value must be large enough to contain all
characters in the value (including decimal point and carriage
return). If max_length is exceeded, the bell is sounded and no
more input is accepted. If the range entered is invalid, the
bell is sounded and the cursor repositioned for another try. The
value entered must be in the range 3.4e-38 to 3.4e+38.
EXAMPLE:
#include
main()
{
double double_in;
col_gdouble(&double_in, 12);
}
__________________________________________________________________
void col_gfloat(float_in, max_length)
float *float_in
int max_length
This routine gets a float value from the console and displays
it in the default foreground and background colors.
NOTES:
The max_length value must be large enough to contain all
characters in the value (including decimal point and carriage
return). If max_length is exceeded, the bell is sounded and no
more input is accepted. If the range entered is invalid, the
bell is sounded and the cursor repositioned for another try. The
value entered must be in the range 3.4e-38 to 3.4e+38.
EXAMPLE:
#include
main()
{
float float_in;
col_gfloat(&float_in, 12);
}
__________________________________________________________________
void col_gint(int_in, max_length)
int *int_in;
int max_length;
This routine get an int value from the console and displays
it in the default foreground and background colors.
NOTES:
The max_length value must be large enough to contain all
characters in the value (including the carriage return).
If max_length is exceeded, the bell is sounded and no
more input is accepted. If the range entered is invalid, the
bell is sounded and the cursor repositioned for another try. The
value entered must be in the range -32768 thru 32767.
EXAMPLE:
#include
main()
{
int int_in;
col_gint(&int_in, 4);
}
__________________________________________________________________
void col_glong(long_in, max_length)
long *long_in;
in max_length;
This routine gets a long value from the console and displays
it in the default foreground and background colors.
NOTES:
The max_length value must be large enough to contain all
characters in the value (including the carriage return).
If max_length is exceeded, the bell is sounded and no
more input is accepted. If the range entered is invalid, the
bell is sounded and the cursor repositioned for another try. The
value entered must be in the range -2147483648 thru 2147483647.
EXAMPLE:
include
main()
{
long long_in;
col_glong(&long_in, 8);
}
__________________________________________________________________
void col_gstring(string_in, max_length)
char string_in[];
int max_length;
This routine gets a string from the console and displays it
in the default foreground and background colors.
NOTES:
The max_length must be large enough to contain all input
characters plus the carriage return. If max_length is exceeded,
the bell is sounded and no more input is accepted. Input is
edited to exclude non-displayable characters, control characters,
alternate characters, and extended keyboard characters (F1, F2,
etc.). Wrapping at the end of a line is controlled by the value
used when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
char string_in[200];
col_gstring(string_in, 45);
}
__________________________________________________________________
void col_gunlong(unlong_in, max_length)
unsigned long *unlong_in;
int max_length;
This routine gets an unsigned long int from the console and
displays it in the default foreground and background colors.
NOTES:
The max_length value must be large enough to contain all
characters in the value (including the carriage return).
If max_length is exceeded, the bell is sounded and no
more input is accepted. If the range entered is invalid, the
bell is sounded and the cursor repositioned for another try. The
value entered must be in the range 0 thru 4294967295.
EXAMPLE:
include
main()
{
unsigned long unlong_in;
col_gunlong(&unlong_in, 9);
}
__________________________________________________________________
void col_gunsigned(unsigned_in, max_length)
unsigned *unsigned_in;
int max_length;
This routine gets an unsigned int from the console and
displays it in the default foreground and background colors.
NOTES:
The max_length value must be large enough to contain all
characters in the value (including the carriage return).
If max_length is exceeded, the bell is sounded and no
more input is accepted. If the range entered is invalid, the
bell is sounded and the cursor repositioned for another try. The
value entered must be in the range 0 thru 65535.
EXAMPLE:
include
main()
{
unsigned unsigned_in;
col_gunsigned(&unsigned_in, 3);
}
__________________________________________________________________
void col_pchar(char_in)
char char_in;
This routine prints a character at the current cursor
position using the default foreground and background colors.
NOTES:
Wrapping at the end of a line is controlled by the value used
when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
col_pchar('A');
}
__________________________________________________________________
void col_pdouble(double_in, num_dec)
double double_in;
int num_dec;
This routine converts a double type to a string and displays
it in the default foreground and background colors.
NOTES:
Num_dec is the number of decimal positions to be displayed.
If more decimal positions exist, the value is rounded. Wrapping
at the end of a line is controlled by the value used when calling
the standard routine _wrapon.
EXAMPLE:
#include
main()
{
double double_print = 1234.4567;
col_pdouble(double_print, 3);
}
RESULT:
1234.457
__________________________________________________________________
void col_pfloat(float_in, num_dec)
float float_in;
int num_dec;
This routine converts a float type to a string and displays
it in the default foreground and background colors.
NOTES:
Num_dec is the number of decimal positions to be displayed.
If more decimal positions exist, the value is rounded. Wrapping
at the end of a line is controlled by the value used when calling
the standard routine _wrapon.
EXAMPLE:
#include
main()
{
float float_in = 123.456;
col_pfloat(float_in, 2);
}
RESULT:
123.46
__________________________________________________________________
void col_pint(int_in)
int int_in;
This routine converts an int type to a string and displays it
in the default foreground and background colors.
NOTES:
Wrapping at the end of a line is controlled by the value used
when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
int int_in;
col_pint(int_in);
}
__________________________________________________________________
void col_plong(long_in)
long long_in;
This routine converts a long type to a string and displays it
in the default foreground and background colors.
NOTES:
Wrapping at the end of a line is controlled by the value used
when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
long long_in;
col_plong(long_in);
}
__________________________________________________________________
void col_pstring(string_in)
char string_in[];
This routine displays a string in the default foreground and
background colors.
NOTES:
Wrapping at the end of a line is controlled by the value used
when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
char string_in[100];
col_pstring(string_in);
}
__________________________________________________________________
void col_punlong(unlong_in)
unsigned long unlong_in;
This routine converts an unsigned long type to a string and
displays it in the default foreground and background colors.
NOTES:
Wrapping at the end of a line is controlled by the value used
when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
unsigned long unlong_in;
col_punlong(unlong_in);
}
__________________________________________________________________
void col_punsigned(unsigned_in)
unsigned unsigned_in;
This routine converts an unsigned int type to a string and
displays it in the default foreground and background colors.
NOTES:
Wrapping at the end of a line is controlled by the value used
when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
unsigned unsigned_in;
col_punsigned(unsigned_in);
}
__________________________________________________________________
void get_any_type(string_in, max_string, type_get)
char string_in[];
int max_string;
char type_get;
This routine is the heart of the color input routines of this
library. It edits the characters that can be entered for each
type, limits the number of characters that can be entered
(max_string - 1 to allow for a carriage return), and deletes
characters using the backspace key. All types are returned as a
string and are converted to the proper type in the calling
routine.
NOTES:
The type_get indicators are used as follows:
'S' All characters except non-displayable, control,
alternate, and extended code keys (F1, F2,
etc.).
'I' Numeric and sign characters only.
'U' Numeric characters only.
'F' Numeric and sign characters plus the decimal
point.
EXAMPLE:
#include
main()
{
char string_in[34];
get_any_type(string_in, 34, 'U');
}
__________________________________________________________________
INTRODUCTION
These routines were written using Microsoft C version 5.00 to
implement color input/output on the IBM (or compatible) color
graphics adapter. The routines make use of the graphics routines
in the newer version of Microsoft C. This version of color
implementation is preferable to my previous version which
required calls to interrupt procedures. All required function
declarations, include statements, and global variable definitions
are contained in the color.h file.
Feel free to use these routines whenever and wherever. If you have
any comments, corrections, or suggestions, contact me here under
user-id 75216.2063.
ANDY ECKHARDT
USE OF COLOR ROUTINES
Using the file placement scheme recommended by Microsoft, the
files required for linking in these routines should be placed as
follows:
File Library
color.h \include
color.lib \lib
Linking these routines is accomplished with the following
command:
cl yourpgm /link color
__________________________________________________________________
COLOR ROUTINES
__________________________________________________________________
void bell()
This routine sounds the speaker momentarily. It is used to
signal an obvious error in I/O.
NOTES:
The variable high_val can be altered to create different
pitches and the length of the sound can be changed by altering
the loop ending count.
EXAMPLE:
#include
main()
{
bell();
}
__________________________________________________________________
void clreol()
This routine clears the screen from the current cursor
position to the end of the line and returns the cursor to its
beginning position.
EXAMPLE:
#include
main()
{
clreol();
}
__________________________________________________________________
void col_gchar(char_in)
char *char_in
This routine gets a character from the console. The
character is displayed in the default foreground and background
colors.
NOTES:
The character values entered are edited to exclude non-
displayable characters, control characters, alternate characters,
and extended keyboard characters (F1, F2, etc.).
EXAMPLE:
include
main()
{
char char_in;
col_gchar(&char_in);
}
__________________________________________________________________
void col_gdouble(double_in, max_length)
double *double_in;
int max_length;
This routine gets a double value from the console and
displays it in the default foreground and background colors.
NOTES:
The max_length value must be large enough to contain all
characters in the value (including decimal point and carriage
return). If max_length is exceeded, the bell is sounded and no
more input is accepted. If the range entered is invalid, the
bell is sounded and the cursor repositioned for another try. The
value entered must be in the range 3.4e-38 to 3.4e+38.
EXAMPLE:
#include
main()
{
double double_in;
col_gdouble(&double_in, 12);
}
__________________________________________________________________
void col_gfloat(float_in, max_length)
float *float_in
int max_length
This routine gets a float value from the console and displays
it in the default foreground and background colors.
NOTES:
The max_length value must be large enough to contain all
characters in the value (including decimal point and carriage
return). If max_length is exceeded, the bell is sounded and no
more input is accepted. If the range entered is invalid, the
bell is sounded and the cursor repositioned for another try. The
value entered must be in the range 3.4e-38 to 3.4e+38.
EXAMPLE:
#include
main()
{
float float_in;
col_gfloat(&float_in, 12);
}
__________________________________________________________________
void col_gint(int_in, max_length)
int *int_in;
int max_length;
This routine get an int value from the console and displays
it in the default foreground and background colors.
NOTES:
The max_length value must be large enough to contain all
characters in the value (including the carriage return).
If max_length is exceeded, the bell is sounded and no
more input is accepted. If the range entered is invalid, the
bell is sounded and the cursor repositioned for another try. The
value entered must be in the range -32768 thru 32767.
EXAMPLE:
#include
main()
{
int int_in;
col_gint(&int_in, 4);
}
__________________________________________________________________
void col_glong(long_in, max_length)
long *long_in;
in max_length;
This routine gets a long value from the console and displays
it in the default foreground and background colors.
NOTES:
The max_length value must be large enough to contain all
characters in the value (including the carriage return).
If max_length is exceeded, the bell is sounded and no
more input is accepted. If the range entered is invalid, the
bell is sounded and the cursor repositioned for another try. The
value entered must be in the range -2147483648 thru 2147483647.
EXAMPLE:
include
main()
{
long long_in;
col_glong(&long_in, 8);
}
__________________________________________________________________
void col_gstring(string_in, max_length)
char string_in[];
int max_length;
This routine gets a string from the console and displays it
in the default foreground and background colors.
NOTES:
The max_length must be large enough to contain all input
characters plus the carriage return. If max_length is exceeded,
the bell is sounded and no more input is accepted. Input is
edited to exclude non-displayable characters, control characters,
alternate characters, and extended keyboard characters (F1, F2,
etc.). Wrapping at the end of a line is controlled by the value
used when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
char string_in[200];
col_gstring(string_in, 45);
}
__________________________________________________________________
void col_gunlong(unlong_in, max_length)
unsigned long *unlong_in;
int max_length;
This routine gets an unsigned long int from the console and
displays it in the default foreground and background colors.
NOTES:
The max_length value must be large enough to contain all
characters in the value (including the carriage return).
If max_length is exceeded, the bell is sounded and no
more input is accepted. If the range entered is invalid, the
bell is sounded and the cursor repositioned for another try. The
value entered must be in the range 0 thru 4294967295.
EXAMPLE:
include
main()
{
unsigned long unlong_in;
col_gunlong(&unlong_in, 9);
}
__________________________________________________________________
void col_gunsigned(unsigned_in, max_length)
unsigned *unsigned_in;
int max_length;
This routine gets an unsigned int from the console and
displays it in the default foreground and background colors.
NOTES:
The max_length value must be large enough to contain all
characters in the value (including the carriage return).
If max_length is exceeded, the bell is sounded and no
more input is accepted. If the range entered is invalid, the
bell is sounded and the cursor repositioned for another try. The
value entered must be in the range 0 thru 65535.
EXAMPLE:
include
main()
{
unsigned unsigned_in;
col_gunsigned(&unsigned_in, 3);
}
__________________________________________________________________
void col_pchar(char_in)
char char_in;
This routine prints a character at the current cursor
position using the default foreground and background colors.
NOTES:
Wrapping at the end of a line is controlled by the value used
when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
col_pchar('A');
}
__________________________________________________________________
void col_pdouble(double_in, num_dec)
double double_in;
int num_dec;
This routine converts a double type to a string and displays
it in the default foreground and background colors.
NOTES:
Num_dec is the number of decimal positions to be displayed.
If more decimal positions exist, the value is rounded. Wrapping
at the end of a line is controlled by the value used when calling
the standard routine _wrapon.
EXAMPLE:
#include
main()
{
double double_print = 1234.4567;
col_pdouble(double_print, 3);
}
RESULT:
1234.457
__________________________________________________________________
void col_pfloat(float_in, num_dec)
float float_in;
int num_dec;
This routine converts a float type to a string and displays
it in the default foreground and background colors.
NOTES:
Num_dec is the number of decimal positions to be displayed.
If more decimal positions exist, the value is rounded. Wrapping
at the end of a line is controlled by the value used when calling
the standard routine _wrapon.
EXAMPLE:
#include
main()
{
float float_in = 123.456;
col_pfloat(float_in, 2);
}
RESULT:
123.46
__________________________________________________________________
void col_pint(int_in)
int int_in;
This routine converts an int type to a string and displays it
in the default foreground and background colors.
NOTES:
Wrapping at the end of a line is controlled by the value used
when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
int int_in;
col_pint(int_in);
}
__________________________________________________________________
void col_plong(long_in)
long long_in;
This routine converts a long type to a string and displays it
in the default foreground and background colors.
NOTES:
Wrapping at the end of a line is controlled by the value used
when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
long long_in;
col_plong(long_in);
}
__________________________________________________________________
void col_pstring(string_in)
char string_in[];
This routine displays a string in the default foreground and
background colors.
NOTES:
Wrapping at the end of a line is controlled by the value used
when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
char string_in[100];
col_pstring(string_in);
}
__________________________________________________________________
void col_punlong(unlong_in)
unsigned long unlong_in;
This routine converts an unsigned long type to a string and
displays it in the default foreground and background colors.
NOTES:
Wrapping at the end of a line is controlled by the value used
when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
unsigned long unlong_in;
col_punlong(unlong_in);
}
__________________________________________________________________
void col_punsigned(unsigned_in)
unsigned unsigned_in;
This routine converts an unsigned int type to a string and
displays it in the default foreground and background colors.
NOTES:
Wrapping at the end of a line is controlled by the value used
when calling the standard routine _wrapon.
EXAMPLE:
#include
main()
{
unsigned unsigned_in;
col_punsigned(unsigned_in);
}
__________________________________________________________________
void get_any_type(string_in, max_string, type_get)
char string_in[];
int max_string;
char type_get;
This routine is the heart of the color input routines of this
library. It edits the characters that can be entered for each
type, limits the number of characters that can be entered
(max_string - 1 to allow for a carriage return), and deletes
characters using the backspace key. All types are returned as a
string and are converted to the proper type in the calling
routine.
NOTES:
The type_get indicators are used as follows:
'S' All characters except non-displayable, control,
alternate, and extended code keys (F1, F2,
etc.).
'I' Numeric and sign characters only.
'U' Numeric characters only.
'F' Numeric and sign characters plus the decimal
point.
EXAMPLE:
#include
main()
{
char string_in[34];
get_any_type(string_in, 34, 'U');
}
__________________________________________________________________
December 8, 2017
Add comments