?? mfpshare.doc
字號:
decimal places, and type using the same formatting struct-
ure as printf().
An optional procedure list can be passed which defines
any key or group of keys as "HOT KEYS" that can execute
any function you desire. A PROC list is created by you
that associates any key with any function.
NOTE: Microsoft and Lattice C users, because MFP uses its own
color driver instead of relying on the graphics library
functions, to optimize performance and resultant code size,
the color driver MUST be disabled before exiting to DOS.
This is performed by calling color() and passing it minus
one in the fg and bg parameters, color( -1,-1 ).
7
mfp
MFP FIELD DEFINITION
An MFP field is defined in the following manner:
1) A pointer to the data item.
2) A pointer to the picture format string.
3) The row and column of where the item will be on the screen.
4) The foreground and background attributes of the input field.
5) Optional pointers to the pre and post validation functions.
If pre and post validation is not used, a zero must be placed
in the pre and post validation positions.
The following example will allow the entry of a three character string
converted to uppercase at row 5 column 15 with a black foreground and a
white background without pre or post validation. The field name is
"example_1" and will be referenced by that name in the MFP list.
char buffer[ 4 ];
MFP example_1[] = { buffer, "!!!", 5, 15, BLACK, WHITE, 0, 0 };
^ ^ ^ ^ ^ ^ ^ ^ ^
Field Name -------+ | | | | | | | |
Pointer to data variable --------+ | | | | | | |
Picture formatting string ---------------+ | | | | | |
Row of field location ------------------------+ | | | | |
Column of field location -------------------------+ | | | |
Foreground color of entry field -----------------------+ | | |
Background color of entry field ------------------------------+ | |
Pre validation function pointer -----------------------------------+ |
Post validation function pointer -------------------------------------+
The following example will allow the entry of a five digit decimal integer
at row 10 column 15 with a blue foreground and a black background. Post
validation is performed but no pre validation.
The field name is "example_2" and will be referenced by that name in the
MFP list.
void post(void);
int idata;
MFP example_2[] = { &idata, "%5d", 10, 15, BLUE, BLACK, 0, post };
The following example will allow the entry of a twelve digit double
precision floating point variable with nine digits left of
the decimal point and two digits to the right. Including the
decimal point, that makes up the field length of twelve. The
input field will be located at row 15 column 15 and have a
white foreground and blue background. Pre and post validation
is performed.
The field name is "example_3" and will be referenced by that name in the
MFP list.
void pre(void);
void post(void);
double fdata;
MFP example_3[] = { &fdata, "%12.2lf", 15, 15, WHITE, BLUE, pre, post };
8
mfp
THE MFP LIST
The MFP list array defines which fields are to be entered
and in what order. The fields in the MFP list must be defined.
The MFP list is the first parameter that will be passed to the mfp()
function.
The following example MFP list defines three fields to be inputted.
The three fields were described on the previous pages of this text.
MFP *example[] = { example_1, example_2, example_3, 0 };
The MFP list "example" will tell the mfp() function that fields
example_1, example_2, and example_3 are to be input and in the order
that they appear in the list. When the mfp() function has scanned
and processed all of the defined fields and has read in the zero
it will exit and return control to the calling program.
NOTE: All MFP lists must be terminated with a zero to define the end
of the list.
9
mfp
DATA ENTRY PICTURE FORMATTING
One of the main features that makes MFP stand out is it's
picture or data formatting capability. MFP uses a picture
string to identify the data type and it's characteristics.
Numeric variables are identified with a "%" percent symbol
as the first picture character. Any other symbol in the first
character position forces MFP to assume the data is a character
array. Numeric data is always entered as BASE 10 or decimal.
Character entry is filtered by MFP to not allow control codes into
an entry field.
Character formatting symbols are as follows:
! Upper case conversion. ( alphanumeric )
* Security echo. All characters are allowed.
0 - 9 Numeric characters only, value limited by formatter
A, a Alpha only allowed
H, h Hexadecimal characters only
X, x Any ASCII character
Y, y Y or N only
All others used as stationary objects
Numeric formatting requirements are as follows:
"%nn[.][nn]|[L][l][h]|[d][u][f]"
* The first character must be a percent symbol.
* A length parameter must be provided. This will represent
the entire entry field length including decimal points and sign.
* If a decimal point is provided a decimal length parameter is
required to indicate the number of decimal positions. A decimal
point cannot be used for non-floating point variables.
NOTE: The length parameter must be at least three greater than
the decimal length. ie; "%5.3f" would be illegal, yet "%5.2f"
would be okay.
* Last is the variable type. MFP allows certain modifiers to the
standard variable types. The legal types are as follows:
hd -- Short integer.
d -- Signed integer.
ld -- Signed long integer.
u -- Unsigned integer.
lu -- Unsigned long integer.
f -- Single precision floating point.
lf -- Double precision floating point.
* Lf -- Long double precision floating point.
* Long double is not a standard variable type. Turbo C supports long
double along with a few other compilers. The other versions of this
library converts your long double to a double. If your compiler
supports long double, you may recompile the mfp.c file after changing
the define LONGDOUBLE to equate to TRUE. Then you may replace the MFP
object file in the library.
10
mfp
DATA ENTRY PICTURE FORMATTING (cont'd)
The following are examples of numeric data entry pictures and the
data they may represent:
"%12.2lf" -- 999999999.99
"%5d" -- 32565
"%10lu" -- 9999999999
"%7.4f" -- 99.9999
The following are examples of character data entry pictures and
the data they may represent:
"(999)999-9999" -- Makes a good telephone field. The user can
only enter or position the cursor at the
non-stationary entry positions. The
parenthesis and dashes would be skipped
over allowing entry in only the proper
fields. The "9"s allow any number from zero
to nine to be entered.
"!!!!!!!!!!" -- Ten characters all uppercase. Make sure the
data item can hold ten characters plus a
terminating NULL.
"999-99-9999" -- Social security number entry field.
"!!-999!!!!" -- The first two characters will be uppercase
alphanumeric followed by a dash then three
numeric only characters followed
by four uppercase alphanumerics.
"********" -- Eight character password entry field, all
characters are allowed but only spaces are
displayed.
"99AAA!!!!" -- The first two characters are numeric the next
three are alpha and the last four are uppercase
alphnumeric.
"Y" -- This is a single character entry field for
a 'Y' or an 'N'. Input is converted to upper-
case.
"19/39/99" -- This is a character date entry field. The first
character can be a '1' or '0'. The second can
be any number, The third character is skipped
but is part of the input string. The fourth
character can be anything from '0' to '3'.
"XXXXXXXX" -- This is an eight character entry field. No
uppercase conversion is performed. What you
type is what you get.
11
mfp
FIELD EDITING KEYS
Up Arrow -- Moves cursor to first character of previous field.
If already at the first field, moves cursor to beginning
of field.
Down Arrow -- Moves cursor to first character of next field.
If aleady at last field, exits the editing session and
mfp() returns to calling routine.
Left Arrow -- Moves the cursor left to an input position in the
current field.
Will jump over non-input positions defined in the
field picture.
Has no effect if already at the first input character.
Right Arrow -- Moves the cursor right to an input position in the
current field.
Will jump over non-input positions defined in the
field picture.
Has no effect if already at the last input position.
Ctrl Right -- Moves the cursor to the last input position in the
current field.
Ctrl Left -- Moves the cursor to the first input position in the
current field.
Backspace -- Move cursor to next left input position while deleting
the contents of the input position. Destructive backspace.
Home -- Moves the cursor to the first input position of the first
field.
End -- Ends the edit session. mfp() returns to the calling
function.
Insert -- Puts mfp() into the insert mode allowing characters
that are keyed to be inserted in front of characters
that are positioned to the right. This key is a toggle
which activates and deactivates the insert mode.
Delete -- Deletes the current character and shifts all characters
to the right of the deleted character left once.
Ctrl Backspace -- Deletes the entire entry field and positions cursor to
the beginning of the field.
12
mfp
PRE AND POST VALIDATION
1) Cursor moves into field.
2) Previous contents of field are displayed.
3) Jump to line 6 if no pre-process.
4) Procedure for pre-process is executed.
5) Jump to line 10 if pre-process returned valid as a FALSE.
6) User inputs data into field.
7) Jump to line 10 if no post-process.
8) Procedure for post-process is executed.
9) Skip to line 6 if post-process returned valid as a FALSE.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -