⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mfpshare.doc

📁 多格式数据录入库  
💻 DOC
📖 第 1 页 / 共 5 页
字号:
   10)  This field is finished, onto the next field...

    This describes the decisions mfp() makes when working a field. The
    field processor provides the pre and post validation functions a variety
    of data about the current field. Since the data is global, the pre and
    post validation functions you write can have access to all data in
    all fields allowing a great degree of flexibilty. The mfp() function
    will allow you to perform any type of operation you choose, including
    modifying the field you are entering or other fields.

    MFP provides the following list of global variables for your validation
    functions to use:

  int mfp_valid     --  This variable is used to determine the outcome of your
                        pre or post validation. If the validation fails this
                        variable must be made FALSE. If your validation passes
                        then make it TRUE.

  int mfp_field     --  This variable represents the current field number
                        starting with zero.

  int mfp_update    --  This variable indicates if the fields contents have
                        been changed. Non-zero if changed, zero if not changed.

  void *mfp_data    --  This variable is a pointer to the data item being
                        entered. Your validation function may use this any
                        way you see fit. You may change the data items value
                        or read it directly by using it.

  char *mfp_picture --  This is a pointer to the picture formatting string
                        for the field being entered. You may use it any
                        way you see fit.

  int mfp_row       --  This variable provides your validation function with
                        the screen row the entry field is on.

  int mfp_col       --  This variable provides your validation function with
                        the screen column the entry field is on.

  int mfp_fg        --  This variable provides your validation function with
                        the foreground color of the entry field.

  int mfp_bg        --  This variable provides your validation function with
                        the background color of the entry field.



                                      13

                                                                        mfp
THE PROCEDURE LIST

    The second parameter that can be passed to the MFP function is a
    procedure list that sets up a relationship of keyboard keys to
    functions.

    The procedure is called when the defined key is pressed. When the
    procedure is finished MFP regains control from where it left off.

    The typedef PROC defines a structure that is used to define the
    link between key and function. A PROC variable is defined and a
    list of PROC variables is passed to the MFP function.

    The PROC variable needs the integer key value returned by inkey()
    and a pointer to the function.

    Any key that the inkey() function can detect is legal for use
    as a hot key.

    The following is an example of hot key definitions:

        void help( void );
        void popup_1( void );
        void popup_2( void );

        PROC  hotkey_1[] = { FN1, help };       /* F1 is for help       */
        PROC  hotkey_2[] = { FN2, popup_1 };    /* F2 is a popup menu   */
        PROC  hotkey_3[] = { FN3, popup_2 };    /* F3 is another popup  */

        PROC  *hotkeys[] = { hotkey_1, hotkey_2, hotkey_3, 0 };

    The PROC list "hotkeys" is an array of pointers to variables of type PROC.

    The order in which the hot keys are listed does not affect operation.

    The "hotkeys" variable would be passed as the second parameter in the
    mfp() function call. Any time F1, F2, or F3 were pressed when mfp() was
    executed the functions help(), popup_1(), or popup_2() would execute
    then return control to mfp().

    NOTE: The PROC list, like the MFP list, must be terminated with a
          zero.
















                                      14


MFP EXAMPLE LISTING                                                     mfp

   1:  #include <stdio.h>
   2:  #include <string.h>
   3:  #include <dos.h>
   4:  #include <conio.h>
   5:  #include <ctype.h>
   6:  #include <mfp.h>
   7:  
   8:  void drawscrn( char * );
   9:  void prompts( void );
  10:  void mess24( char *mess );
  11:  void help( void );
  12:  void inst( void );
  13:  
  14:  char                name[ 21 ];
  15:  short int           binarys     = 0;
  16:  int                 rel_lum     = 0;
  17:  long int            sfc_temp    = 0L;
  18:  unsigned int        abs_lum     = 0;
  19:  unsigned long int   age_yrs     = 0L;
  20:  float               magnitd     = 0.0;
  21:  double              distance    = 0.0;
  22:  long double         mass        = 0.0;
  23:  
  24:  MFP ln1[] = { name,"!!!!!!!!!!!!!!!!!!!!", 5,20,BLACK,WHITE,inst,0 };
  25:  MFP ln2[] = { &binarys,  "%2hd",     7,20,BLACK,WHITE,inst,0 };
  26:  MFP ln3[] = { &rel_lum,  "%6d",      9,20,BLACK,WHITE,inst,0 };
  27:  MFP ln4[] = { &abs_lum,  "%6u",     11,20,BLACK,WHITE,inst,0 };
  28:  MFP ln5[] = { &sfc_temp, "%9ld",    13,20,BLACK,WHITE,inst,0 };
  29:  MFP ln6[] = { &age_yrs,  "%9lu",    15,20,BLACK,WHITE,inst,0 };
  30:  MFP ln7[] = { &magnitd,  "%9.3f",   17,20,BLACK,WHITE,inst,0 };
  31:  MFP ln8[] = { &distance, "%13.3lf", 19,20,BLACK,WHITE,inst,0 };
  32:  MFP ln9[] = { &mass,     "%20.3Lf", 21,20,BLACK,WHITE,inst,0 };
  33:  
  34:  MFP *lst[] = { ln1, ln2, ln3, ln4, ln5, ln6, ln7, ln8, ln9, 0 };
  35:  
  36:  PROC p1[] = { FN1, help };
  37:  PROC p2[] = { FN2, fast };
  38:  
  39:  PROC *plist[] = { p1, p2, 0 };
  40:  
  41:  void main()
  42:  {
  43:      int yorn;
  44:      drawscrn("MFP Demonstration Program");
  45:      prompts();
  46:      do
  47:      {
  48:          mess24("Please enter above data...");
  49:          ed_list = lst;
  50:          mfp( lst, plist  );
  51:          mess24("[ OPTIONS ]  <E>dit, <S>ave, or <A>bort  (E/S/A) ");
  52:          do
  53:          {
  54:              yorn = inkey();
  55:          }
  56:          while( !yorn );
                                      15


MFP EXAMPLE LISTING (cont'd)                                            mfp

  57:          yorn = toupper( yorn );
  58:          if( yorn == 'S' )
  59:          {
  60:              mess24("Saving data...");
  61:          }
  62:      }
  63:      while( yorn == 'E' );
  64:      color( WHITE, BLACK );
  65:  }
  66:  
  67:  void drawscrn( char *header )
  68:  {
  69:      char buf[ 11 ];
  70:      int x;
  71:      color( WHITE, BLACK );
  72:      clrscr();
  73:      color( BLACK, WHITE );
  74:      wcls( 1,1, 2,80 );
  75:      color( WHITE, BLACK );
  76:      for( x = 3 ; x < 25 ; x++ )
  77:      {
  78:          cup( x,1 );
  79:          putch(186);
  80:          cup( x,48 );
  81:          putch(179);
  82:          cup( x,80 );
  83:          putch(186);
  84:      }
  85:      color( BLACK, WHITE );
  86:      wcls( 24,1, 24,80 );
  87:      cup( 1, 2 );
  88:      print( ldate( buf ) );
  89:      cup( 1,71 );
  90:      print( strtime( buf ) );
  91:      x = strlen( header );
  92:      cup( 2, (80-x)/2 );
  93:      print(header);
  94:      color( WHITE, BLACK );
  95:      wcls( 25,1, 25,80 );
  96:      cup( 25,2 );
  97:      print("F1 Help | F2 Jump | F3      | F4      | ");
  98:      print("F5      | F6      | F7      | F8      ");
  99:  }
 100:  
 101:  void prompts( void )
 102:  {
 103:      color( CYAN, BLACK );
 104:      cup( 5,4 );
 105:      print("Stellar Ident:");
 106:      cup( 7,4 );
 107:      print("  System Size:");
 108:      cup( 9,4);
 109:      print(" Relative Lux:");
 110:      cup( 11,4 );
 111:      print(" Absolute Lux:");

                                      16


MFP EXAMPLE LISTING (cont'd)                                            mfp

 112:      cup( 13,4 );
 113:      print(" Surface Temp:");
 114:      cup( 15,4 );
 115:      print("  Stellar Age:");
 116:      cup( 17,4 );
 117:      print("    Magnitude:");
 118:      cup( 19,4 );
 119:      print("  Light Years:");
 120:      cup( 21,4 );
 121:      print("         Mass:");
 122:      color( WHITE, BLACK );
 123:  }
 124:  
 125:  void mess24( char *mess )
 126:  {
 127:      color( BLACK, WHITE );
 128:      wcls( 24,2,24,76 );
 129:      cup( 24,2 );
 130:      print( mess );
 131:  }
 132:  
 133:  char *name_txt[] = {    "Please enter the name",
 134:                          "of the stellar system.",
 135:                          "",
 136:                          "The name can be any",
 137:                          "combination of letters",
 138:                          "or numbers up to twenty",
 139:                          "characters long.",
 140:                          0
 141:                      };
 142:  char *size_txt[] =  {   "Please enter the number",
 143:                          "of stellar mass bodies",
 144:                          "in this system.",
 145:                          "",
 146:                          "A binary system would",
 147:                          "have two stellar masses.",
 148:                          "",
 149:                          "A system like our sun's",
 150:                          "would have only one.",
 151:                          0
 152:                      };
 153:  char *lux_txt[] =   {   "Please enter the relative",
 154:                          "intensity of the stellar",
 155:                          "system in units of lux.",
 156:                          "",
 157:                          "This must be the relative",
 158:                          "value not the absolute.",
 159:                          "",
 160:                          "This value may be positive",
 161:                          "or negative with limits to",
 162:                          "+/- 32000.",
 163:                          "",
 164:                          "It also must be a whole",
 165:                          "number.",
 166:                          0
 167:                      };
                                      17


MFP EXAMPLE LISTING (cont'd)                                            mfp

 168:  char *alux_txt[] =  {   "Please enter the absolute",
 169:                          "intensity of the stellar",
 170:                          "system in units of lux.",
 171:                          "",
 172:                          "This must be the absolute",
 173:                          "value and not the relative.",
 174:                          "",
 175:                          "This value must be positive.",
 176:                          "Largest value cannot exceed",
 177:                          "65,535. It must also be a",
 178:                          "whole number.",
 179:                          0
 180:                      };
 181:  char *sftp_txt[] =  {   "Please enter the surface",
 182:                          "temparature in degrees",
 183:                          "Kelvin.",
 184:                          "",
 185:                          "The measured temparature",
 186:                          "must be in whole degrees",
 187:                          "and may be positive or",
 188:                          "negative.",
 189:                          "",
 190:                          "In the case of a multiple",
 191:                          "unit system, please enter",
 192:                          "the average temparature.",
 193:                          0
 194:                      };
 195:  char *age_txt[] =   {   "Please enter the age of",
 196:                          "the system in years.",
 197:                          "",
 198:                          "The age can be approximated",
 199:                          "by the apparent luminosity",
 200:                          "and the surface temp.",
 201:                          "",
 202:                          "The age cannot exceed 32",
 203:                          "billion years.",
 204:                          0
 205:                      };
 206:  char *magn_txt[] =  {   "Please enter the magnitude",
 207:                          "of the largest body in this",
 208:                          "system.",
 209:                          "",
 210:                          "The magnitude of this system",
 211:                          "can be entered as a floating",
 212:                          "point value.",
 213:                          0
 214:                      };
 215:  char *ltyr_txt[] =  {   "Please enter the distance",
 216:                          "from gravitaional center of",
 217:                          "our solar system to the",
 218:                          "gravitational center of",
 219:                          "this system.",
 220:                          "",

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -