Dec 192017
 
Screen control function library for MS and Turbo C.
File SLIB11.ZIP from The Programmer’s Corner in
Category C Source Code
Screen control function library for MS and Turbo C.
File Name File Size Zip Size Zip Type
CONSOLE.H 4329 1547 deflated
EXAMPLE.C 1684 643 deflated
EXAMPLE.EXE 25698 16715 deflated
EXAMPLE.LNK 57 39 deflated
EXAMPLE.STR 1263 439 deflated
IBMPC.H 2141 765 deflated
MANUAL.DOC 47290 12698 deflated
READ.ME 1434 648 deflated
SCREEN.LIB 9216 3971 deflated
SCREEN1.C 4826 1475 deflated
SCREEN2.C 2978 1006 deflated
SCREEN3.C 2860 955 deflated

Download File SLIB11.ZIP Here

Contents of the READ.ME file



December 8, 1986


Requirements:

Microsoft C compiler
small memory model
MS-LINK version 3.51+
The linkage editor (LINK) provided with most versions of
MS-DOS/PC-DOS <> be used.



This package contains an object module library (screen.lib)
of functions for Microsoft's C compiler (small model).
The functions in the library enable the programmer to
create data entry screens.


Files example.c, screen1.c, screen2.c and screen3.c are the
source code files for the example program that is included.
The example program also documents screen function design and
data entry program design.


File "manual.doc" is the manual for the functions.

The design shown in the example program is simple. A "real
world" application will require a complex control center,
most probably with database function calls.


To create the example program, compile the four C source code files.
(Microsoft's C compiler (version 4.0) was used to create the functions
in the library. Use the small memory model.) Link the files using the
command:

LINK @EXAMPLE.LNK

The linkage editor response file EXAMPLE.LNK assumes SCREEN.LIB is in
the current directory or that an environment variable has been set
so that the linkage editor can locate the file SCREEN.LIB.


Contents of the MANUAL.DOC file



December 8, 1986


Requirements:

Microsoft C compiler
small memory model
MS-LINK version 3.51+
The linkage editor (LINK) provided with most versions of
MS-DOS/PC-DOS <> be used.



This package contains an object module library (screen.lib)
of functions for Microsoft's C compiler (small model).
The functions in the library enable the programmer to
create data entry screens.


Files example.c, screen1.c, screen2.c and screen3.c are the
source code files for the example program that is included.
The example program also documents screen function design and
data entry program design.


File "manual.doc" is the manual for the functions.

The design shown in the example program is simple. A "real
world" application will require a complex control center,
most probably with database function calls.


To create the example program, compile the four C source code files.
(Microsoft's C compiler (version 4.0) was used to create the functions
in the library. Use the small memory model.) Link the files using the
command:

LINK @EXAMPLE.LNK

The linkage editor response file EXAMPLE.LNK assumes SCREEN.LIB is in
the current directory or that an environment variable has been set
so that the linkage editor can locate the file SCREEN.LIB.






SCREEN PROGRAM DESIGN AND SOFTWARE LIBRARY
MICROSOFT C VERSION 1.1

August 1986

DAR Research
Milwaukee, WI

Copyright (c) 1986 by DAR Research
All Rights Reserved


WARRANTY


DAR Research makes no warranties, either express or implied, that
this software will be error free. DAR Research makes no
warranties concerning the suitability of this software for any
particular application. In no event shall DAR Research be held
liable for any direct or indirect damages claimed to be caused by
use of this software. This includes, but is not limited to, loss
of profit, business, interruption of business, or anticipation of
profit.

If you do not like the software, erase it: you should not have
paid anything for it anyway.






























- 1 -









Table of Contents

LICENSING................................................. 3

INTRODUCTION.............................................. 4

EFINPUT() - EDITED FIELD INPUT............................ 6

INPUT FIELD ATTRIBUTES.................................... 8

CONTROL KEYS.............................................. 13
Programmer Defined...................................... 13
Pre-Defined............................................. 14

OUTPUT FIELD ATTRIBUTES................................... 16

DISPS() - DISPLAY SCREEN.................................. 17

DISPIF() - DISPLAY INPUT FIELD............................ 18

DISPOF() - DISPLAY OUTPUT FIELD........................... 19

PRINTEM() - PRINT ERROR MESSAGE........................... 20

DISPLAY ATTRIBUTES........................................ 21

LIMITS AND RESTRICTIONS................................... 22

CAUTIONS - HOW TO STAY OUT OF TROUBLE..................... 23

EXAMPLE PROGRAM........................................... 24

MISCELLANEOUS FUNCTIONS................................... 25
access()................................................ 25
beep().................................................. 26
dmprint() - Direct Memory PRINT......................... 26

INDEX..................................................... 27


















- 2 -









LICENSING


The functions provided in file "screen.lib" can be included in
commercial software without any royalties. The complete set of
software, source and object, included in this package can be
reproduced and shared with other people on the condition that
there is NO CHARGE for any copy and that all associated files
(read.me, screen.lib, console.h, ibmpc.h, example.exe, example.c,
example.str, screen1.c, screen2.c, screen3.c and manual.doc) are
included.

No donations are requested for use of this software.

Source code can be purchased. Write DAR Research for details.

Support is offered to registered users of the software.
Registration costs $50 for one year of support (from date
registration is received). Support will be provided through
written correspondence. Telephone support is not available.
Registered users will also be informed of software updates, if
any, for one year. Correspondence should be directed to the
address shown below. Checks should be made out to "DAR Research".

DAR Research
c/o
Dean A. Roth
P.O. Box 11095
Milwaukee, WI 53211



























- 3 -









INTRODUCTION


A set of functions are included to create screens that perform
limited edited data entry. The programmer is freed from
repeating code to test the validity of a field's contents on a
character basis. The programmer must still provide range tests.
This software is oriented toward the experienced applications
developer.

The object module library "screen.lib" contains the functions for
creating data entry screen and programs. Each field in a screen
is assigned attributes. For example, one attribute specifies the
row a field is to be displayed on a monitor. Another attribute
specifies the column.

Attributes can be assigned to a field to limit the set of legal
characters. For example, the character set for numeric fields
should be restricted to digits 0 - 9, "+" and "-", and possibly a
decimal point.

An example program is included in source and executable form. It
shows how to construct screens and a data entry, or screen,
program.

The files listed below should be included:

- read.me
- screen.lib
- console.h
- ibmpc.h
- example.exe
- example.c
- example.str
- screen1.c
- screen2.c
- screen3.c
- manual.doc

The functions bypass the operating system for console I/O and
write directly to the screen buffer. This produces nearly
instantaneous screen displays. However, the algorithm used in
this version of the software can produce "snow" on some color
displays when a new screen is displayed.

An example program is included: files example.c, example.str,
screen1.c, screen2.c and screen3.c. It is ready to be compiled
and requires three special #include files: example.str, console.h
and ibmpc.h.

Files "console.h" and "ibmpc.h" will be required in your
applications. File "console.h" contains structure definitions
and #defines. File "ibmpc.h" contains keyboard #defines specific
to IBM's PC computer family.


- 4 -









Specify library "screen.lib" as the first library to be searched
by the linkage editor.






















































- 5 -









EFINPUT() - EDITED FIELD INPUT


Efinput() performs character level editing. It detects when an
illegal character has been entered. Programmer written code must
detect range errors (value too small or too large).

Input fields are defined as an array of structures of type
"infield". Each input field is assigned several attributes when
it is defined. For example, one attribute specifies the legal
character set. (Character set options are described in chapter
"INPUT FIELD ATTRIBUTES" under topic "Icharset".) Another
attribute specifies if decimal places are permited. If a
character is not a member of the specified character set, a
message will be printed on the error line (line 24) and the bell
will beep. For example, only digits, "-", "+" and sometimes a
decimal point are valid for numeric fields. All other characters
are illegal for numeric fields.

Fields will be processed in the order in which they are defined.

Function efinput() operates in two modes. One mode is the typical
data entry mode. The cursor stops at each active input field and
the program pauses until data is entered. A second mode, called
fast forward, causes each field to be edited, but the program
will not pause for data entry until the end of the current screen
is reached or an edit error is detected. The fucntion can detect
certain types of errors, such as an empty field that requires
data to be entered. Programmer written code must detect other
types of errors, such as range errors.

SYNOPSIS

int efinput(fieldptr, field, nfields, error)

struct infield *fieldptr; /* pointer to input field structure */
int *field; /* current field being processed */
int nfields; /* total number of fields */
int error; /* When non-zero, exit fast forward mode */

Arguments to efinput() are:

fieldptr
Pointer to the first "infield" structure in an array.
Typically this would simply be the name of the input field
array. If a screen has one input field rather than several
fields, then use the "&" operator (address of).

field
Pointer to an int which records the current field being
processed. Fields are always numbered from zero (beginning
with offset zero into the array of input field structures).
Notice that the address, not the value, is passed to
efinput(). The value of "field" can be altered by efinput().


- 6 -










nfields
The number of fields in the input field array. The value must
always be the total number of fields, not the number ON or
anything else. This value is best calculated by the compiler
using a macro like:

#define NFIELDS(x) (sizeof(x)/sizeof(x[0]))

The value will always be determined at compile time, and it
will always be correct nomatter how many changes are made to
the input fields.

error
The "error" argument to efinput() must be non-zero when
programmer written code detects an error. The argument must
be zero otherwise. The example program (files example.c,
screen1.c, screen2.c and screen3.c) show one possible
implementation. A non-zero value signals efinput() to
deactivate fast forward mode if the mode is active.

The "error" variable should be reset to zero immediately
after return from efinput().

The "error" variable can be used in any manner. Often it will
contain an error message number. Another function might fetch
the error message from a file. (Putting error messages in a
file helps assure consistency between programs.)

The chapter "INPUT FIELD ATTRIBUTES" for a detailed description
of structure "infield" and all input field attributes.

The source for an example program is included. The files
example.c, screen1.c, screen2.c and screen3.c demonstrate one
possible implementation and the usage of efinput().





















- 7 -









INPUT FIELD ATTRIBUTES


Structure "infield" is listed below. It defines an input field.
Each structure member is an attribute. Each attribute is
described below.

struct infield
{
char Ionoff;
char Irow;
char Icolumn;
char Iwidth;
char Idattr;
char Ifieldtype;
char Idecimals;
char Icharset;
char Iflags;
char *Ivalid;
union alltypes *Ivarptr;
};

Ionoff
Two legal values: ON and OFF. The contents of an input field
will be displayed when a field is ON and the contents of
Ivalid is non-zero (field has valid data). Data entry is
enabled when ON. Data entry is disabled when OFF (cursor will
skip field).

ON and OFF are defined in file "console.h".

Irow
The row on the screen where display will occur. Rows are
numbered 1 through 25. A field should reside on one row.

Icolumn
The column on the screen where display will begin. Columns
are numbered 1 through 80.

Iwidth
The width - maximum number of characters that can be entered
- of a field.

Caution must be exercised. If a field is an integer value
and ints have a range of 32767 to -32768, then an int field
should be restricted to four characters. A five character int
field may not return the expected result. If a field is a
character array, the variable must be one greater than the
width for the NULL ('\0') character.

Fields can vary from one to eighty characters. It is expected
that a field will reside on one row.

The width of a field will be delineated whenever a display


- 8 -









attribute is used that is visible when a space is printed.
For example, if display attribute UDIM (underscored dim) is
specified and a monochrome display controller is used, then a
field's width will be delineated by an underscore even when
the field does not contain any data.

Trailing spaces in character array fields are truncated to
the first non-space character.

Idattr
The display attribute for a field. The result of an attribute
depends upon the type of monitor that is installed. See
chapter "Display Attributes" for attribute options and
detailed information.

The width of a field will be delineated whenever a display
attribute is used that is visible when a space is printed.
For example, if display attribute UDIM (underscored dim) is
specified and a monochrome display controller is used, then a
field's width will be delineated by an underscore even when
the field does not contain any data.

Ifieldtype
This attribute identifies the data type associated with the
field. The data will be converted to this type. For example,
if a field is specifed to be type INT (int), then data will
be converted to int (binary) before being stored at the
location pointed to by attribute "Ivarptr".

The character set for a field must be consistent with the
data type. Therefore, a field type if INT (int) can consist
of digits and an optional sign: all other characters are
illegal. Also, the field width must not allow illegal
values. For example, a five character wide INT field will
allow values to 99999. However, anything over 32767 is
invalid (two bytes are used for int by the compiler).

Field type tags are #defined in file "console.h" and listed
below.

TAG MEANING

INT Integer (int)
SHORT Short integer (short)
UNSIGNED Unsigned integer (unsigned)
LONG Long integer (long)
FLOAT Single precision floating point (float)
DOUBLE Double floating point (double)
CHAR Single character (char)
CARRAY Character array (string)






- 9 -









Idecimals
The number of decimal places for floating point values. If a
field's width is five and two decimal places are specified,
then two digits to the left of the decimal point can be
entered. Entry of a decimal point where it is illegal is
detected. Entry of more digits to the right of a decimal
point is detected and disallowed.

The position of a decimal point is automatically adjusted if
a negative or positive sign (- or +) is entered.

A decimal point is allowed in a numeric field when a value
other than zero is specified for the number of decimal
places. Otherwise a decimal point is not allowed in numeric
fields.

Icharset
This attribute specifies the valid character set for a field.
For example, a floating point field can include digits and a
decimal point, or only digits. Codes are:

CHARACTER SET
CODE DESCRIPTION COMMENT

0 Digits and '.' only Decimal places specified
-or-
Digits only No decimal places

1 Letters, digits or spaces
2 Letters or digits
3 Letters or spaces
4 Letters A-Z and a-z
5 Any printable character
6 Y or N Always uppercase

Letters are automatically converted to uppercase when the
FUCASE flag is specifed in the Iflags attribute.

If a character is not a member of the specified character
set, then one of the messages listed below will be printed on
line 24, the error message line. Error messages are:

ERROR MESSAGES

Digits and '.' only
Digits only
Letters, digits or spaces
Letters or digits
Letters or spaces
Letters A-Z and a-z
Any printable characters
Y or N
Decimal point already entered
Decimal point required


- 10 -









Max digits to right of decimal entered
Unknown character set type
'+' and '-' must be first character when used

When a non-supported key is pressed, the message is:

Key not supported

Function keys are active when FFKEY is specified in the
Iflags attribute. See screen function screen1.c for an
example usage of the F1 key as a help key (context sensitive
help). (Help messages are often stored in a file. They are
indexed according to field. The required text for a field is
read only when needed. A separate function to select and
display help text provides a more sophisticated and probably
useful implementation of "help".)

Iflags
Six flags can be specifed. All can be specified at once,
though FNONE should be used alone.

FREQ
The FREQ flag indicates that data must be entered before
efinput() will relinquish control (except for certain
"control" function keys).

The message "A value must be entered" will be displayed
on the error message line (line 24) if data is entered
and the Return/Enter, Tab, down arrow or PgDn key is used
to exit a FREQ field.

FRREQ
The FRREQ flag specifies that the RETURN/ENTER key must
be pressed to exit the field. This is usually used with
FREQ.

If FRREQ is not specified, data entry will be terminate
for a field when the maximum number of characters for the
field, as specified in Iwidth, have been entered.

The message "Press RETURN/ENTER to continue" will be
displayed on the error message line (line 24), but the
bell will not beep.

FUCASE
The FUCASE flag forces all letters to be converted to
uppercase.

FFKEY
The FFKEY flag is used to indicate that function keys F1
through F10 are active for a field. A function key, such
as F1, might be used as a "help" key. See example screen
function screen1.c for an example help key
implementation.


- 11 -










FMFILL
Requires that the number of characters specified in
Iwidth be entered. Therefore if Iwidth is 4, four
characters must be entered. If not enough characters are
entered, the error message "Field must be filled" will be
displayed.

This flag implicitly makes a field required (FREQ). An
empty FMFILL field will be trapped when efinput() is in
"FAST FORWARD" mode, and reported as "Value required". An
FMFILL field can only have zero or Iwidth number of
characters.

FNONE
Use the flag FNONE when no flags are wanted.

Multiple flags can be specified through use of the bit-wise
OR operator (FREQ|FRREQ|FFKEY).

Ivalid
This attribute will be non-zero when a field has valid data,
and zero when a field contains garbage. This attribute should
always be tested before a field is used in a calculation or
report. The contents of the field are valid only when Ivalid
is non-zero.

Attribute Ivalid is a pointer. Consequently, whenever
reference is made the Ivalid being zero or non-zero, it
actually means the CONTENTS of Ivalid must be zero or
non-zero. Correct code to test for zero or non-zero would be:

if (*iscreen[field].Ivalid) /* test of zero or non-zero */

For example, a character array field may contain a string,
but if the Ivalid attribute is zero, the data is not valid.
This is especially important when differentiating between
values of zero and garbage data. (Many programmers have used
zero to indicate a "missing" or garbage value. However,
there was no way to differentiate between an intentional
value of zero and zero meaning missing data.)

The value in Ivalid has no other meaning and should not be
used for any other purpose.

Ivarptr
Pointer to the variable where a field's data will be stored.

NOTE: do not cast the pointer to (union anytype *). The
pointer should be cast, but some compilers do not correctly
process casts in a structure initialization at compile time.





- 12 -









CONTROL KEYS


Some control keys must be implemented by the programmer. Other
control keys have a pre-defined meaning. The source code for the
example program shows one implementation of programmer defined
control keys.



PROGRAMMER DEFINED

Escape
Cancel operation command. The original contents, if any, of
current field are restored and control returns to the
function that called efinput() with the return code "CANCEL".
Escape, therefore, also acts as an "undo" command.

The programmer must decide how to process CANCEL. It can be
ignored by making an entry in the switch statement on the
return value from efinput() for CANCEL that is a "continue"
statement. Data entry will then continue with the same field,
and escape will be an "undo" command.

PgUp
"PgUp" is usually used to signal that the previous screen is
wanted. The example programs show how one possible
implementation. The programmer can choose a different
implementation of PgUp. When PgUp is pressed, the action
listed below will occur for any and all implementations.

The original contents, if any, of the current field are
restored and control is returned to the function that called
efinput() with the return code "PREVSCREEN". PdUp,
therefore, also acts as an "undo" command.

PgDn
"PgDn" is usually used to signal that the next screen is
wanted.

The original contents, if any, of the current field are
restored and control is returned to the function that called
efinput() with the return code "NEXTSCREEN". Escape,
therefore, also acts as an "undo" command.

Function efinput() ceases to perform data entry unless an
input field attribute rule is violated or edit code in the
user written function that calls efinput() detects an error.
The function returns with the code RETURN.

An error detected in user written code is passed to efinput()
through argument "error". The argument is an int, and
"error" should be non-zero to indicate that an error occured.
The "error" argument should be reset to zero immediately


- 13 -









after return from efinput(), as in the example screen
functions.

The value in "error" is typically an error message number.
Messages may be stored in a file or be compiled into a
program. However, efinput() only cares if "error" is zero or
non-zero.

The programmer can alter the implementation of PgDn. It can
be ignored by making a case for PgDn that is a continue, and
setting the "error" switch to non-zero. The code can also be
used for other purposes, such as invoking a help screen.
(Many software systems use function key F1 as the help
signal.)

F1 - F10
Function keys must be programmer implemented. Function keys
must be enabled by specifying FFKEY in the Iflags attribute.
If FFKEY is not specified for a field, keys F1 through F10
will be ignored.

When function keys are enabled, pressing a function key will
produce this action: the original contents of the current
field will be restored and control will be returned to the
function that called efinput(). The return code will be F1KEY
through F10KEY, whatever is appropriate. Function keys,
therefore, can also act as an "undo" command.

See file "screen1.c" for an example of a simple
implementation of F1 as a context sensitive help key.



PRE-DEFINED

Home
"Home" is used to go to the first input field of the current
screen.

The original contents, if any, of current field are restored,
the "current field" variable (argument "error" to efinput())
is set to zero (first field), and control is returned to the
function that called efinput() with return code "HOME".

Up arrow
The "up arrow" key is used to select a prior field (move the
cursor to the first previous active field). This is a "go to
previous field" command.

The original contents of a field are always restored before
any action is undertaken. Therefore PgUp also acts as an
"undo" command: any changes to a field will be ignored.

The first field must never be turned OFF (Ionoff must always


- 14 -









be ON).

Down arrow
The "down arrow" key is treated exactly as the RETURN/ENTER
key.

Return/Enter
The RETURN/ENTER key is used to signal the end of data entry.
If a field has the REQ attribute, an error occurs if no data
has been entered.

The down arrow and tab keys act exactly the same as the
RETURN/ENTER key.

Tab
Acts exactly the same as the RETURN/ENTER key.

BackTab
Acts exactly the same as the up arrow (previous field) key.
Backtab is shift-tab.

Backspace
Erases the character to the left of the cursor. If the cursor
is at the left margin of the field, then the character under
the cursor will be erased.

Del
Erases the character under the cursor.

space - numeric fields
The space bar acts the same as the "Del" key for numeric
fields.
























- 15 -









OUTPUT FIELD ATTRIBUTES


Structure "outfield" is listed below. The members of the
structure, field attributes, are described below.

struct outfield
{
char Oonoff;
char Orow;
char Ocolumn;
char Odattr;
char Owidth;
char *Otextptr;
};

Oonoff
Specifies whether the field should be displayed or ignored.
If the field is turned OFF, a width must be specified in
order for the field to be erased. A width of zero means to
display the field until all characters in the string pointed
to by Otextptr have been displayed.

Orow
The row on the screen where display is to begin. Rows are
numbered 1 through 25. An output field is expected to reside
on one row.

Ocolumn
The column on the screen where display is to begin. Columns
are numbered 1 through 80.

Odattr
Display attribute. See chapter "Display Attributes" for
attribute options (DIM, BRIGHT, RDIM, etc.) and detailed
information.

Owidth
The maximum width for a field. Zero has the special meaning
to display until end-of-string: no padding will occur.
Owidth can range from 0 to 80.

If the specified width is greater than the length of the
string pointer to by Otextptr, the field will be padded with
spaces using the field's display attribute. This is
equivalent to erase to end-of-field.

Otextptr
Pointer to a NULL terminated string (normal C string). The
string can be a NULL string. A NULL (empty) string can be
used to erase a field when a field width is also specified.





- 16 -









DISPS() - DISPLAY SCREEN


Displays a "screen". A screen is composed of output and input
fields. Functions dispif() and dispof() can be used to display
input and output fields, respectively, also.

SYNOPSIS

void disps(out, n_out, in, n_in);

struct outfield *out;
int n_out; /* number of fields */
struct infield *in;
int n_in; /* number of fields */


Typical usage:

static struct outfield oscreen[] =
{
(definition of fields)
};

static struct infield iscreen[] =
{
(definition of fields)
};


disps(oscreen, NFIELDS(oscreen), iscreen, NFIELDS(iscreen));


Macro "NFIELDS" is defined in file "console.h" to calculate the
number of fields (oscreen and iscreen are arrays of structures).





















- 17 -









DISPIF() - DISPLAY INPUT FIELD


Displays an "input" field as defined by structure "infield" in
file "console.h". Attributes for input fields are defined by
members of the structure "outfield". See the document for
function efinput() for a description of input field attributes.

Structure "infield" defines a field in which data will be
entered. Usually several fields will be defined in an array of
"infield" structures.

Function dispif() can be used to display all or any number of
fields in an array of infield structures.


SYNOPSIS

void dispif(fieldptr, nfields)

struct outfield *fieldptr;
int nfields; /* number of fields to display */


Typical usage:

static struct infield iscreen[] =
{

(definition of fields)

};


dispif(iscreen, sizeof(iscreen)/sizeof(iscreen[0]));
-or-
dispif(&iscreen[4], 1);
-or-
dispif(iscreen, NFIELDS(iscreen));

Macro "NFIELDS" is defined in file "console.h" to calculate the
number of fields.














- 18 -









DISPOF() - DISPLAY OUTPUT FIELD


Displays an "output" field (prompt) as defined by structure
"outfield" in file "console.h". Attributes for output fields are
defined by members of the structure "outfield".

Structure "outfield" defines an output only, or prompt, field.
These fields are usually the labels for data entry fields, such
as "Last Name". Usually several fields will be defined in an
array of outfield structures.

Function dispof() can be used to display all or any number of
fields in an array of outfield structures.

SYNOPSIS

void dispof(fieldptr, nfields)

struct outfield *fieldptr;
int nfields; /* number of fields to display */


Typical usage:

static struct outfield oscreen[] =
{

(definition of fields)

};


dispof(oscreen, sizeof(oscreen)/sizeof(oscreen[0]));
-or-
dispof(&oscreen[4], 1);
-or-
dispof(oscreen, NFIELDS(oscreen));

Macro "NFIELDS" is defined in file "console.h" to calculate the
number of fields.















- 19 -









PRINTEM() - PRINT ERROR MESSAGE


Prints an error message on the "error message line", line 24, and
beeps the bell. The message is printed with display attribute
BRIGHT.

SYNOPSIS

void printem(msg);

char *msg;


Typical usage:

printem("Valid range is 5.00 - 99.99");

-or-

static char emsg[] =
{
"", /* never used - 0 == no error */
"message 1",
"message 2",
"message 3"
};

if (error)
printem(emsg[error]);

See the source code for the example screen functions (screen1.c,
screen2.c and screen3.c) for another example.























- 20 -









DISPLAY ATTRIBUTES


Six display attributes are defined.

EFFECT
ATTRIBUTE MONOCHROME DISPLAY COLOR DISPLAY
FOREGROUND BACKGROUND

DIM normal white on black normal white black
BRIGHT high intensity white on black red black
UDIM normal white underscored normal white blue
UBRIGHT high intensity white on black bright white blue
RDIM black on normal white normal white black
RBRIGHT black on normal white bright white black

The attributes are defined in two external arrays of int. The
monochrome attributes are defines in A_MONO. The color display
attributes are defined in A_COLOR. Each array consists of six
integers. Each element has the meaning as the order of attributes
listed above (subscript zero is DIM, subscript five is RBRIGHT).

New values can be assigned to the attributes, if desired. See a
technical manual for attribute options for monochrome and color
display controllers.































- 21 -









LIMITS AND RESTRICTIONS


1. Values are not checked. Invalid attributes will cause
unpredictable behavior.

2. The first input field of each screen must always be ON.

3. The last input field of each screen must always be ON.

4. An input field must fit on one row.

5. An input field is limited to 80 characters.

6. A FRREQ field needs one extra space at its end. The cursor
will stop at that position when the field is filled with
characters until the RETURN/ENTER key is pressed.

7. Always check the Ivalid attribute of a field before using the
data. Attribute Ivalid is a pointer. Consequently, whenever
reference is made the Ivalid being zero or non-zero, it
actually means the CONTENTS of Ivalid must be zero or
non-zero. Correct code to test for zero or non-zero would be:

if (*iscreen[field].Ivalid) /* test of zero or non-zero */































- 22 -









CAUTIONS - HOW TO STAY OUT OF TROUBLE


1. Know the limits (maximum and minium values and sign
extension) and size (number of bytes) of each C data type
(int, char, double, etc.).

2. Test attribute "Ivalid" before using data. Ivalid will be
non-zero when a field has valid data, otherwise it will be
zero.

Attribute Ivalid is a pointer. Consequently, whenever
reference is made the Ivalid being zero or non-zero, it
actually means the CONTENTS of Ivalid must be zero or
non-zero. Correct code to test for zero or non-zero would be:

if (*iscreen[field].Ivalid) /* test of zero or non-zero */

3. Reset attribute "Ivalid" to zero whenever a field is OFF. One
statement can perform this job. See the example screen
functions.

4. Add one extra byte for character arrays. The byte is used for
the terminating NULL ('\0') character. Use the coding
standard of writing "+ 1" when specifying the size of a
character array. For example, "char name[10+1];".

5. If you turn a field OFF, you must provide for turning it ON.




























- 23 -









EXAMPLE PROGRAM


Source code files and an executable file of an example program
have been included. File "example.exe" is the executable file.
Files example.c, screen1.c, screen2.c, screen3.c and example.str
constitute the program. Files console.h and ibmpc.h are #included
files that will be used in your applications.

File "example.c" is the control center for the program. Action
is taken depending upon the return code from each screen, such as
"PgUp" as the command for the previous screen, if there is a
previous screen.

The example program shows one possible implementation of a
context sensitive help key in screen1.c.

Two levels of editing are used in screen two (screen2.c). There
is a pre-input edit and post-input edits. In the pre-input edit,
the value of a field prior to F_MODEL is check. According to the
value of the prior field, field F_MODEL is either active (ON) or
inactive (OFF). When the field is OFF, the cursor will not stop
at the field. The Ivalid attribute should be reset (set to zero)
when an input field is inactive (OFF).

Each field is identified with a #defined tag, such as field
"F_MODEL". The use of tags to identify fields generally produces
more maintainable code. If fields are added or deleted, a
field's number need be changed in only one location, which
reduced the possibility of error.

The post-input edits are generally range tests. A more
comprehensive date test should be used in screen one. (A library
of date and time routines is a very useful collection of
functions.)

The files are ready to be compiled. When linking the program,
specify library "screen.lib" as the first library.


















- 24 -









MISCELLANEOUS FUNCTIONS



ACCESS()

Access() can be used to determine if a file exists and if it can
be accessed with the specified mode. Access() will detect when a
drive is not ready under program control, avoiding the operating
system message

"abort, retry, ignore"

Access() can be used to test if a disk drive (or network virtual

drive) is ready (door open, no diskette, etc.).

If an error occurs (return of -1), check the external int "errno"
for the specific error (see error list "ERRNO.H"). Errors are
ENOENT and EACCES.

SYNOPSIS

int access(pathname, mode)

char *pathname; /* file pathname */
int mode; /* permission setting */
Modes
0 - check for existance only
2 - check for write permission
4 - check for read permission
6 - check for read and write permission

returns: 0 if file has given mode
-1 indicates file does not exist, or is not
accessable with the given mode

Examples:

if (access(filename, 0))
{
perror();
exit(1);
}


if (access(filename, 0))
switch (errno)
{
case EACCES : /* Drive not ready */
(code...)
break;

case ENOENT : /* file not found */
(code...)


- 25 -









break;
}



BEEP()

Function beep() beeps the computer's bell once.

SYNOPSIS

void beep(void);



DMPRINT() - DIRECT MEMORY PRINT

Function dmprint() writes data directly to the active display
controller's buffer. Therefore, special characters, such as
control-g (bell), carriage return, line feed, etc., are not
recognized as special.

SYNOPSIS

void dmprint(row, column, width, attribute, buffer)

char row; /* 1 - 25 */
char column; /* 1 - 80 */
char width; /* 0 - 80 (zero has special meaning) */
char attribute; /* DIM, BRIGHT, etc. */
char *buffer; /* pointer to character string */




Typical usage:

dmprint((char) 24, (char) 1, (char) 80, BRIGHT, "Value required");

-or-

static char *msg[] =
{
"Value required",
"Invalid month",
etc.
};

dmprint((char) 24, (char) 1, (char) 80, BRIGHT, msg[error]);







- 26 -









Index



--- A ---

access(), 25
A_COLOR, 21
A_MONO, 21
Attributes
Display, 21
Icharset, 10
Icolumn, 8
Idattr, 9
Idecimals, 10
Ifieldtype, 9
Iflags, 11
Input Fields, 8
Ionoff, 8
Irow, 8
Ivalid, 12
Ivarptr, 12
Iwidth, 8
Ocolumn, 16
Odattr, 16
Onoff, 16
Orow, 16
Otextptr, 16
Output Fields, 16
Owidth, 16



--- B ---

Backspace Key, 15
Backtab Key, 15
beep(), 26



--- C ---

console.h, 4
Control Keys
Backspace, 15
Control keys
Backtab, 15
Control Keys
Del, 15
Down Arrow, 15
Escape, 13
F1 - F10, 14
Home, 14


- 27 -









PgDn, 13
PgUp, 13
RETURN/ENTER, 15
space bar, 15
Tab, 15
Up Arrow, 14



--- D ---

Data entry mode, 6
Del Key, 15
dispif(), 18
Display Attributes, 21
Idattr, 9
Odattr, 16
dispof(), 19
disps(), 17
dmprint(), 26
Down Arrow Key, 15



--- E ---

EACCES, 25
efinput(), 6
ENOENT, 25
errno, 25
Error Message Line, 10, 11, 20
Escape Key, 13



--- F ---

F1 - F10, 14
Fast forward mode, 6, 7, 12
FFKEY, 11
Flags
FFKEY, 11
FMFILL, 12
FNONE, 12
FREQ., 11
FRREQ, 11
FUCASE, 11
FMFILL, 12
FNONE, 12
FREQ., 11
FRREQ, 11
FUCASE, 11
Function Keys, 11, 14



- 28 -









--- H ---

Home Key, 14



--- I ---

ibmpc.h, 4
Icharset, 10
Icolumn, 8
Idattr, 9
Idecimals, 10
Ifieldtype, 9
Iflags, 11
Input Field Attributes, 8
Ionoff, 8
Irow, 8
Ivalid, 12
Ivarptr, 12
Iwidth, 8



--- N ---

Next Field Control Key, 15



--- O ---

Ocolumn, 16
Odattr, 16
Oonoff, 16
Orow, 16
Otextptr, 16
Output Field Attributes, 16
Owidth, 16



--- P ---

PgDn Key, 13
PgUp Key, 13
Previous Field Control Key, 14
printem(), 20








- 29 -









--- R ---

RETURN/ENTER Key, 15



--- S ---

Space Key - numeric fields, 15



--- T ---

Tab Key, 15



--- U ---

Up Arrow Key, 14



































- 30 -





 December 19, 2017  Add comments

Leave a Reply