📄 mfpdemo.c
字号:
*/
wcls( 5,50, 21,79 );
/*
Display the text for the particular field.
The field selection is done by the value of mfp_field.
*/
while( num_txt[ mfp_field ][ x ] )
{
cup( 7+x,50 );
print( num_txt[ mfp_field ][ x++ ] );
}
}
void cinst()
{
/*
This function is called in the prevalidation test of each entry field.
Instead of prevalidation this function displays text on the right hand
side of the display.
*/
auto int x = 0;
color( WHITE, BLUE );
wcls( 5,50, 21,79 );
while( char_txt[ mfp_field ][ x ] )
{
cup( 7+x,50 );
print( char_txt[ mfp_field ][ x++ ] );
}
}
void help()
{
/*
This function provides general level help.
It is selected by the user pressing the F1 key.
*/
static char buf[ 4096 ];
/*
Save the entire screen to buf...
*/
scrswp( buf, 0 );
/*
The help will be red on white...
*/
color( RED, WHITE );
/*
Clear rows 24 and 25 on the screen...
*/
wcls( 24,1,25,80 );
/*
Display the requested help message...
*/
mess24("Your outta luck: no help available, press any key...");
/*
Wait until the user presses a key...
*/
pause();
/*
Restore the entire screen to its original state...
*/
scrswp( buf, 1 );
}
void npost()
{
/*
General post validation function for numeric entry section...
*/
static int r, c, yorn;
/*
Buffer for screen storage and retrieval
*/
static char buf[ 410 ];
/*
Was the field changed ?
*/
if( !mfp_update )
return;
/*
Determine the position for the message box...
*/
r = mfp_row + 1;
c = mfp_col + 1;
/*
Save the area of screen memory that will be used by the message
box to our buffer for later screen restoration...
*/
w_swap( r, c, r + 4, c + 40, 0, buf );
/*
Make the box red on white...
*/
color( RED, WHITE );
/*
Clear the area for the box...
*/
wcls( r, c, r + 4, c + 40 );
/*
Draw the box outline with a double line...
*/
box( r, c, r + 4, c + 40, 1 );
/*
Place the cursor in position for the message...
*/
cup( r + 2, c + 2 );
/*
Display the approriate query based upon, the field we are at...
*/
switch( mfp_field )
{
case 0:
print("Stellar name correct ? (Y/N) ");
break;
case 1:
print("System size correct ? (Y/N) ");
break;
case 2:
print("Relative lux correct ? (Y/N) ");
break;
case 3:
print("Absolute lux correct ? (Y/N) ");
break;
case 4:
print("Surface temp correct ? (Y/N) ");
break;
case 5:
print("Stellar age correct ? (Y/N) ");
break;
case 6:
print("Magnitude correct ? (Y/N) ");
break;
default:
print("Light years correct ? (Y/N) ");
break;
}
/*
Remove any pending keystrokes...
*/
flush();
/*
Await a users reponse
*/
do
{
yorn = inkey();
} while( !yorn );
/*
Put the original screen contents back...
*/
w_swap( r, c, r + 4, c + 40, 1, buf );
/*
Return with the desired validation result...
*/
if( yorn == 'Y' || yorn == 'y' )
mfp_valid = TRUE;
else
mfp_valid = FALSE;
}
void cpost()
{
/*
Generic post validation for our character entry screen...
*/
static int r, c, yorn;
/*
Buffer for screen storage and retrieval
*/
static char buf[ 410 ];
/*
Was the field changed ?
*/
if( !mfp_update )
return;
/*
Determine the position for the message box...
*/
r = mfp_row + 1;
c = mfp_col + 1;
/*
Save the area of screen memory that will be used by the message
box to our buffer for later screen restoration...
*/
w_swap( r, c, r + 4, c + 40, 0, buf );
/*
Make the box red on white...
*/
color( RED, WHITE );
/*
Clear the area for the box...
*/
wcls( r, c, r + 4, c + 40 );
/*
Draw the box outline with a double line...
*/
box( r, c, r + 4, c + 40, 1 );
/*
Place the cursor in position for the message...
*/
cup( r + 2, c + 2 );
/*
Display the approriate query based upon, the field we are at...
*/
switch( mfp_field )
{
case 0:
print("First name correct ? (Y/N) ");
break;
case 1:
print("Last name correct ? (Y/N) ");
break;
case 2:
print("Street correct ? (Y/N) ");
break;
case 3:
print("City correct ? (Y/N) ");
break;
case 5:
print("Zip code correct ? (Y/N) ");
break;
case 6:
print("Home phone correct ? (Y/N) ");
break;
case 7:
print("Work phone correct ? (Y/N) ");
break;
case 8:
print("SSN correct ? (Y/N) ");
break;
}
/*
Remove any pending keystrokes...
*/
flush();
/*
Await a users reponse
*/
do
{
yorn = inkey();
} while( !yorn );
/*
Put the original screen contents back...
*/
w_swap( r, c, r + 4, c + 40, 1, buf );
/*
Return with the desired validation result...
*/
if( yorn == 'Y' || yorn == 'y' )
mfp_valid = TRUE;
else
mfp_valid = FALSE;
}
void state()
{
/*
Validate a state entry...
*/
static int r, c;
/*
List of correct state initials...
*/
static char *starray = "ALAKAZARCACZCOCTDEDCFLGAGUHIIDILINIAKSKYLAMEMD\
MAMIMNMSMOMTNENVNHNJNMNYNCNDOHOKORPAPRRISCSDTNTXUTVTVIVAWAWVWIWY \0\0";
char *ste;
static char buf[ 410 ];
ste = mfp_data;
/*
Is there data in this field ?
*/
if( !ste[ 0 ] )
return;
/*
Parse the state array for a match
*/
for( r = 0 ; starray[ r ] ; r += 2 )
if( ste[ 0 ] == starray[ r ] )
if( ste[ 1 ] == starray[ r + 1 ] )
break;
if( !starray[ r ] )
{
/*
No match was found, so we have an incorrect state entry...
*/
/*
Determine our position on the screen for our message box...
*/
r = mfp_row + 1;
c = mfp_col + 1;
/*
Save the area for the box to a buffer so we can restore the
original contents of the screen.
*/
w_swap( r, c, r + 4, c + 40, 0, buf );
/*
Draw our message box...
*/
color( RED, WHITE );
wcls( r, c, r + 4, c + 40 );
box( r, c, r + 4, c + 40, 1 );
/*
Let the user know he screwed-up!
*/
cup( r + 2, c + 4 );
print("Invalid State, press any key.\007");
pause();
/*
Put the screen back to it's original state...
*/
w_swap( r, c, r + 4, c + 40, 1, buf );
/*
Mark the validation as failed...
*/
mfp_valid = FALSE;
}
}
void datest()
{
/*
Perform a date verfication
*/
static char buf[ 410 ];
static char cdte[ 11 ], tdte[ 11 ];
int r, c;
char *dte;
mfp_valid = TRUE;
/*
Setup a pointer to the field data...
*/
dte = mfp_data;
/*
Is there data in the field ?
*/
if( !dte[ 0 ] )
return;
/*
Convert the short date to a long date by placing a "19" in front
of the year...
*/
cdte[ 0 ] = dte[ 0 ];
cdte[ 1 ] = dte[ 1 ];
cdte[ 2 ] = dte[ 2 ];
cdte[ 3 ] = dte[ 3 ];
cdte[ 4 ] = dte[ 4 ];
cdte[ 5 ] = dte[ 5 ];
cdte[ 6 ] = '1';
cdte[ 7 ] = '9';
cdte[ 8 ] = dte[ 6 ];
cdte[ 9 ] = dte[ 7 ];
cdte[ 10 ] = '\0';
/*
Convert the date to a numeric then convert the numeric back into
a date.
cdte -- input date.
tdte -- output date created by converting the numeric result of
cdte back into a character date.
The idea is, if the date is illegal the conversion process will fail
and produce a different date string.
*/
jul_str( str_jul( cdte ), tdte );
/*
Test the date strings...
*/
if( strcmp( tdte, cdte ) )
{
/*
Determine our location...
*/
r = mfp_row;
c = mfp_col + 10;
/*
Save a small piece of screen memory to buf...
*/
w_swap( r, c, r + 4, c + 40, 0, buf );
/*
Clear the area of screen memory and draw a box...
*/
color( RED, WHITE );
wcls( r, c, r + 4, c + 40 );
box( r, c, r + 4, c + 40, 1 );
/*
Put our nasty-gramm in the box...
*/
cup( r + 2, c + 4 );
print("Invalid Date, press any key.\007");
pause();
/*
Restore the screen back to it's original state...
*/
w_swap( r, c, r + 4, c + 40, 1, buf );
/*
Mark the validation as failed, so the user can correct the entry...
*/
mfp_valid = FALSE;
}
}
void signoff()
{
cup( 2,1 );
puts("Thank you, for giving the MFP1 demo a test-drive!\n");
puts("The source code to this demo was supplied to give you the");
puts("opportunity to see the MFP1 library in use.\n");
puts("The MFP1 library of data entry, menuing, and screen control");
puts("is available directly from Pride Software Advancement Corp.,");
puts("users groups, and distributers.\n");
puts("If you have any questions or comments about the MFP1 library,");
puts("please contact us at Pride, (305)731-1085, (800)940-2333. If you");
puts("prefer to write, 3575 N.W. 31 Avenue Oakland Park, FL 33309.\n");
puts("================================================================\n");
puts("This demonstration software is released to the public domain for");
puts("the sole purpose of informing the programming community about the");
puts("MFP1 library of programming tools.\n");
puts("You may distribute this software, at no charge, with all the");
puts("files contained on the original distribution diskette.");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -