?? mfpshare.doc
字號:
Determines if there is another line of text to be displayed for this
field. It treats the help_txt variable as a two dimensional array. When
the array points to a zero value it indicates that we are at the end of
the help text for this field. The first array dimension is indexed by
the mfp_field variable which indicates what field number we are at any
given point. The second dimension indexes which line of text is being
referenced.
Line 258:
Displays the line of text pointed to by the two dimensional pointer,
help_txt. The 'x' indexer is post incremented to point to the next line.
Lines 255 - 258:
Loop until a zero value is resolved. This zero is stored at the end of
each field help string set.
24
MFP RUN TIME ERROR MESSAGES
MFP generates very few run time messages, mostly because of its
structure. The error checking that MFP does perform is mostly limited
to the mfp() function itself and primarily only to picture formatting
and input field declaration. MFP will not generate field overflow or
other like messages - it is only concerned about your definitions, which
are hard-coded by you. Unless you write self-modifying code, you should
not expect messages from MFP. If you do get messages from MFP and you
know that your declarations are correct, be on the lookout for ill-
behaved memory usage. For instance, when you clear an array's contents
make sure you are remaining within its boundries, if you go beyond, you
will be destroying possible string space or even worse, the program itself.
*ERROR* Picture Format Invalid -> <your format here>
This error is generated when mfp is extracting the variable type
out of your picture string. No match was found for the nine data
types that mfp supports. Mfp expects the following data types and
cannot understand any others - also watch out for upper and lower
case. Any picture format that begins with a "%" symbol is assumed
by mfp() to be a numeric and will be type checked as one and must
have the following type identifiers at the end of the picture
string : "ld","hd","d","lu","u","Lf","lf","f". If your picture
string begins without the "%" symbol, mfp() will assume that the
entry is a character string or array.
*ERROR* Missing format length -> <your format here>
This error is generated when mfp is setting up the input field
length. This error occurs only on numeric entry fields. If you
neglected to pass a length modifier in your picture format, you
can expect to see this error message. Numeric entry picture strings
MUST have a length modifier so mfp() can build an entry field of
that size for your user to input the data. The mfp() function makes
no assumptions about field length for any numeric type. A properly
declared picture for a five digit unsigned long integer would look
like "%5lu". Mfp uses the '5' to build an entry field five characters
in length.
*ERROR* Length too short -> <your format here>
This error occurs only on floating point numeric entry with a
decimal point involved in the picture. When mfp() gets the field
length and the number of digits to the right of the decimal point,
it checks to see if you have given enough room in the field length
for the sign, decimal point itself, and one digit to the left. This
means that mfp() needs at least a field length of three digits more
than the number of digits to the right of the decimal. For example
if you wanted to define a field for the entry of a floating point
number that had four decimal digits to the right of the decimal,
the minimum field length would be seven digits, "%7.4f". If you
were to define a field as, "%10.8lf", mfp() would give you this
error message because it couldn't build the field in ten digits and
work properly. The proper definition would be, "%11.8lf" or "%10.7lf".
The above examples are only minimums, you may exceed the minimums as
your application demands, ie; "%12.2lf","%10.2Lf","%4.0f","%5f"...
25
===============================================================================
MENU
===============================================================================
Function User menu function with HOT key support.
Syntax int menu( MENU **menulist, PROC **proclist )
Prototype in mfp.h
Remarks Returns an integer value representing the menu option selected.
The return value would be from zero to N - 1. If the user
presses the escape key, a value of -1 is returned.
The menu() function presents to the user your menu and the help
text if provided. The user knows which menu option he is at
by menu() highlighting the current option. The user navigates
through the menu list via the standard cursor keys. The user
may also select an option by pressing the appropriate key,
this immediatly selects the option with one keypress. The user
may also press the escape key and menu() will return with a -1.
When the user cursors over to the wanted selection, he must
press enter to validate the selection and menu() returns with
the integer value of his selection.
The menu() function also supports HOT key PROC's. You must
provide a PROC list, exactly as in mfp(). If the user presses
a PROC key, the menu() function will execute the PROC and
return back to the menu when completed.
The menu() function requires a MENU list. This list is a
group of menu items in the order of value you want returned.
The first item of a menu list, if selected, will have a value
of zero; the second item will have a value of one; and so-on
for the rest. The MENU list MUST be terminated with a zero to
identify the end of the list.
The menu() function can accept a PROC list for HOT key PROC
capability. If you don't wan't PROC key support you must
pass a zero as the PROC parameter.
26
menu
MENU ITEM DEFINITION:
Each menu item is defined using the typedef MENU. This
simplifies your coding and makes defining a menu a snap.
An example menu item is defined as follows:
MENU item1[] = { 10, 20, "Edit", 'E', "Edit the above data." };
The typedef MENU is followed by an item name which must be
unique. The item must be declared as an array. The array is
to be defined by direct assignment using the equals symbol
followed by an open brace.
The first parameters in the braces are the row and column
respectively. This is the row and column where this item will
appear on the screen.
The next parameter is the item text that will be displayed.
Following the item text is the alternate keyboard key that
can also be used to select this item. If this key is pressed,
this item will be selected and menu() will return with this
menu item's value. This parameter MUST be uppercase, because
the keyboard input will be converted to uppercase for testing.
Last but not least, is the optional help text that will be
displayed when this menu item is highlighted. If you do not
want any help text to be displayed, you must place a zero in
this parameter.
Finally the menu declaration must be terminated with a close
brace and a semicolon.
THE MENU LIST:
The menu list directs menu() to show the menu items in the
order you established in the list, the return value starting
from zero indicates the selection the user made, the first item
in the menu list being zero and the last; N - 1. The menu list
MUST be terminated with a zero. The menu list must be declared
with the typedef MENU as an array of pointers.
MENU *menulist[] = { item1, item2, item3, 0 };
THE MENU COLOR:
The menu function defaults to a white on black menu with
the highlighted selection being black on white. This can
be altered by changing the value of the following global
variables that menu() uses:
MENNORMFG This is the normal menu foreground attribute.
MENNORMBG This is the normal menu background attribute.
MENLITEFG This is the highlighted foreground attribute.
MENLITEBG This is the highlighted background attribute.
27
menu
THE HELP TEXT:
The help text parameter is displayed when the user
navigates to a menu item that has a help text line
declared other than a zero. This text must not go beyond
the 80th column. The help text line is cleared before
the text is displayed so shorter lines won't appear with
the remnents of a previous longer line.
The help text is defaulted to be displayed on row 25
column 1 with a WHITE on BLACK attribute with a maximum
text length of 80 characters.
The help text position and attributes can be changed by
modifying the contents of the following global variables:
MENHLPROW This is a global integer that is used for
the row position of the menu help text.
MENHLPCOL This global integer is used for the column
position of the menu help text.
MENHLPLEN This global integer is used to determine
the maximum length of the help text. This,
plus the MENHLPCOL, cannot extend past column
80 on the screen. MENHLPCOL + MENHLPLEN <= 80
MENHLPFG This global integer is used for the foreground
attribute of the help text color.
MENHLPBG This global integer is used for the background
attribute of the help text color.
The above variables are declared in the mfp library and
prototyped for you in mfp.h. To change one or more of the
the above items you only need to assign the value with an
assignment statement, ie;
MENHLPROW = 2;
This assignment changed the help text row to row 2. Any
changes to these variables are global and remain until
changed again.
MENU INITIAL POSITIONING:
The initial menu selection can be preset within the
range of menu options present.
MENSELPOS -- This is the global menu initial position
variable. It is normally set to (-1), this
makes the menu start at the top item. Any
other value of 0 to n-1 will highlite the
appropriate selection.
The menu function does not modify the value of MENSELPOS.
MENSELPOS is a signed integer.
28
menu
EXAMPLE:
#include <stdio.h>
#include <mfp.h>
MENU item1[] = { 10,20, "1) Accounts receivable.", '1', 0 };
MENU item2[] = { 12,20, "2) Accounts payable....", '2', 0 };
MENU item3[] = { 14,20, "3) Payroll.............", '3', 0 };
MENU item4[] = { 16,20, "4) General ledger......", '4', 0 };
MENU item5[] = { 20,20, "Exit...................", 'Q',
"Exit this program to DOS..." };
MENU *mainmenu[] = {
item1, item2, item3, item4, item5, 0
};
{
int menu_sel;
do
{
clrscr();
menu_sel = menu( mainmenu, 0 );
switch( menu_sel )
{
case 0:
accrecv();
break;
case 1:
accpay();
break;
case 2:
payroll();
break;
case 3:
genldgr();
break;
default:
break;
}
} while( menu_sel != 4 && menu_sel != -1 );
return;
}
29
===============================================================================
PIC
===============================================================================
Function Single line character entry with picture formatting.
Syntax char *pic( char *data, char *picture )
Prototype in mfp.h
Remarks
Pic() returns a pointer to the character string provided as
the data parameter. It acts as a replacement for gets(),
with all the line editing features of mfp(). A character
picture string is required. Pic() terminates when the user
presses the enter or escape key. Since the same keys are used
for editing as in mfp(), pic is an ideal choice for single
field entry.
The escape key clears the input field and pic terminates.
Pic() pads any trailing white space with
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -