home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / database / edit_22 / editor.doc < prev    next >
Encoding:
Text File  |  1988-06-11  |  23.6 KB  |  499 lines

  1.                              Data Entry Editor
  2.  
  3.  
  4. One of the most important things in applications program development is the
  5. actual data entry itself.  Data entry would appear to be the simplest part
  6. of any applications project on the surface, yet almost every programmer has
  7. sweated and worried about the actual procedures, seemingly all out of propor-
  8. tion to the task at hand.
  9.  
  10. Over the last few years, numerous magazine articles, indeed entire chapters
  11. in computer programming texts, have been devoted to the importance of accurate
  12. and efficient data entry.  But with all the stress on its importance, little
  13. has been said about the methodology itself, leaving that to the programmer
  14. or analyst to determine.
  15.  
  16.  
  17.                           Data Entry Methodology
  18.  
  19. Data entry collects three basic types of data: character strings, whole
  20. (integer) numbers and real (decimal) numbers.
  21.  
  22. Character strings are comprised of a group of alphabetic and/or numeric
  23. characters, with the alphabetic characters in either upper, lower or mixed
  24. case and are entered from left to right (left justified).  Whole numbers
  25. (integers) are comprised of numeric characters and, unlike the Roman influenced
  26. alphabetic characters, are derived from the Arabic right to left (or right
  27. justified) notation.  The historically more recent decimal notation shares
  28. both influences with the integer portion of the number right justified and
  29. the decimal portion left justified.
  30.  
  31. As you can see, simply manipulating each of the three principal data types
  32. can be considerably confusing for data input procedures.  For instance,
  33. entering the integer value "123" should appear on the data entry screen as:
  34.  
  35.               0 the default "mask",
  36.               1 the first character entered,
  37.              12 the second character entered,
  38.             123 the third character entered.
  39.  
  40. Note that the entry stays right justified; that is, each numeric character
  41. entered "pushes" the preceding character(s) leftward, leaving the most
  42. recently entered character in the rightmost column.
  43.  
  44. Decimal values are a bit more complex.  As shown below, the integer values
  45. must remain right justified, while the decimal values are left justified
  46. expanding from the decimal position rightward.  Thus, the value "123.45"
  47. should appear on the entry screen as:
  48.  
  49.               0.00 the default "mask",
  50.               1.00 the first character entered,
  51.              12.00 the second character entered,
  52.             123.00 the third character entered,
  53.             123.40 decimal is toggled and the fourth character entered,
  54.             123.45 the fifth character entered.
  55.  
  56. Note that the decimal must be "toggled"; that is, the decimal or "." key
  57. must be pressed to signal the beginning of the decimal portion of the numeric
  58. entry or the integer portion must be entirely filled.
  59.  
  60. In comparison, alpha-numeric entries (strings) would seem quite simple and
  61. straight-forward.  But are they?  Depending on the needs of the data input
  62. operator, alpha-numeric entries can be quite complex, particularly when
  63. upper case alphabetic characters, numeric characters and lower case characters
  64. must be mixed in a specific order.  For example, a part number could require
  65. the first two characters of the field be numeric, the third character to be
  66. upper case alphabetic, and the balance of the part number to be numeric as
  67. shown below:
  68.  
  69.             12B34567 the part number,
  70.             ||______ numeric characters only,
  71.               |_____ uppercase alphabetic,
  72.                ||||| numeric characters only.
  73.  
  74. By using a "mask", the data entry could readily provide character-by-character
  75. editing to ensure that the numeric values are placed in a specific position
  76. within the field and that the alphabetic character is an upper case character,
  77. regardless if the shift key is pressed (thus saving a keystroke for the
  78. input operator).
  79.  
  80. Using the "#" character to indicate a numeric character and "U" to indicate
  81. an upper case alphabetic character the mask would appear thus: "##U#####". 
  82. If an alphabetic character was input into the numeric portion of the part
  83. number, a tone would sound, indicating to the input operator that an error
  84. had occurred and allow the input operator to make the correction before
  85. continuing.
  86.  
  87.                            Using the EDITOR.TPU
  88.  
  89. Data entry normally requires more than one data field be entered.  While the
  90. screen design and field placement is left to the programmer or analyst, the
  91. EDITOR.TPU makes the placement and field length fairly easy to determine. 
  92. This version of EDITOR.TPU is fairly simplistic in that it is not ABSOLUTELY
  93. "bulletproof" and allows numeric entry into an alphabetic position within
  94. the field; however, this TPU will suffice for about 95% of all data entry
  95. needs (see "Registration Note" at the end).
  96.  
  97.                            DATA ENTRY PROCEDURES
  98.  
  99. Five basic procedures are called from the TPU: EditDate(), EditString(),
  100. EditInt(), EditReal() and EditChoice().  However, to use more than one
  101. field, the variables "FieldNo" and "LastField" must be initialized in the
  102. originating program and handled on a "Case" basis as noted below:
  103.  
  104.  
  105. {$V-}                                    { Turn off string checking }
  106.  
  107. Var                                      { Program global declarations }
  108.   Var1    : String[5];
  109.   Var2    : Real;
  110.   Var3    : LongInt;
  111.   Var4    : String[8];
  112.   Var5    : String[1];
  113.  
  114. Procedure GetEntry;
  115. Begin
  116.   FieldNo := 1;                          { Set beginning field }
  117.   LastField := 5;                        { Set last field number }
  118.   Var1    := '';                         { Initialize String value }
  119.   Var2    := 0;                          { Initialize LongInt value }
  120.   Var3    := 0.0;                        { Initialize Real value }
  121.   Var4    := '  /  /';                   { Initialize Date }
  122.   Var5    := '';
  123.   Var6    := '';
  124.   Repeat
  125.     Case FieldNo of
  126.       1 : EditString(Var1,5,5,2,15,0,'     '); { String }
  127.       2 : EditReal(Var2,6,5,7,2,15,0);         { Real Number }
  128.       3 : EditInt(Var3,5,5,9,15,0);            { LongInt }     
  129.       4 : EditDate(Var4,5,11,15,0);            { Date }
  130.       5 : EditChoice(Var5,5,13,'Y','N',15,0);  { Choice 'Y/N' }
  131.     End; { Case }
  132.   Until FieldNo > LastField;
  133.          { if the operator "bails out" }
  134.   If Escape then 
  135.   Begin
  136.     gotoXY(30,25);
  137.     Write('Save current record (Y/N)? ');
  138.     EditChoice(Var6,58,25,'Y','N',14,0);
  139.   End;
  140.   If (not Escape) or ((Escape) and (Var6 = 'Y')) then
  141.   Begin
  142.     (* data, record and/or file handling procedure(s) *)
  143.                            .
  144.                            .
  145.   End;
  146. End; { Procedure }
  147.  
  148.  
  149. The apparently simple procedure shown above covers considerable complexity
  150. within the EDITOR.TPU.  Three basic entry types are given: String, Real and
  151. LongInt (Var1, Var2 and Var3).  Note that Var2 *MUST* be declared as LongInt.
  152.  
  153.                                STRING INPUT
  154.  
  155. The EditString() procedure is declared as follows:
  156.  
  157.         GetStr(Variable name,
  158.                        Field length,
  159.                        X position,
  160.                        Y position,
  161.                        Foreground color,
  162.                        Background color,
  163.                        Input mask);
  164.  
  165. The variable name is self-explanatory.  Field length should be declared as
  166. the size of the variable string and, although it can be either longer or
  167. shorter than the declared string length, the declared variable string length
  168. (String[n];) will be the actual data size and will either expand or truncate
  169. the input data.
  170.  
  171. The X and Y positions are equivalent to the Turbo Pascal "gotoXY()" statement
  172. and positions the first character in the entry field on the data entry
  173. screen.  A certain amount of caution should be used with windows in that the
  174. window values may be different than the default "Window(1,1,80,25)".
  175.  
  176. The input mask, when used, may show "U", "#", "*" or spaces.  The placement
  177. of each masking character is important in that the characters input from the
  178. keyboard will follow the mask rules explicitly.  The String mask may be
  179. merely spaces, indicating that any normal keyboard entry (excluding <Ctrl>
  180. and <Alt> characters) are allowable.  The "U" character in the mask will
  181. change the input character to upper case where applicable.  The "#" character
  182. in the mask requires a numeric key to be pressed before any further data
  183. entry will be continued.  If an alphabetic character is attempted in this
  184. mask position, a tone or "beep" will sound and the cursor will remain in
  185. position until a numeric key is pressed.
  186.  
  187. The "*" character in the edit mask is used as a "jump-over" character allowing
  188. fields such as telephone and Social Security numbers to be entered without
  189. having to enter the "-" character.  The character(s) that will actually
  190. appear in the field MUST be declared in the field initialization.  Note also
  191. that use of the "jump-over" character imposes certain field editing restric-
  192. tions.  (See "Field Editing")
  193.  
  194. For example:
  195.  
  196. 'UU###' will reformat the first two entered characters to upper case,
  197.         and require that the last three characters be entered as numeric
  198.         characters.
  199.  
  200. 'UU   ' will reformat the first two entered characters to upper case and
  201.         allow any succeeding characters following except <Ctrl> and <Alt>
  202.         characters.
  203.  
  204. '     ' allows any characters except <Ctrl> and <Alt> characters for the full
  205.         length of the field.
  206.  
  207. ' U   '    forces the second character to upper case and allows the first,
  208.         third, fourth and fifth characters in the field to be any character
  209.         except <Ctrl> and <Alt> characters.
  210.  
  211. ' *   ' allows any character in the first position, "jumps over" the
  212.         second position, and allows any characters in the third, fourth
  213.         and fifth position.
  214.  
  215. Remember that using the "#" character in the mask creates a "demand" entry
  216. in that only numeric characters can be entered before data entry can continue.
  217.  
  218.  
  219.                                NUMERIC INPUT
  220.  
  221. The EditInt() procedure is declared as follows:
  222.  
  223.          EditInt(Variable name,
  224.               Field length,
  225.               X position,
  226.               Y position,
  227.               Foreground color,
  228.                  Background color);
  229.  
  230. The variable name, field length, X position and Y position are the same as
  231. the EditString() procedure.  However, unlike the EditString() procedure, no
  232. field mask is required.  Instead, the actual value of the integer will be
  233. displayed and the integer value of the variable is returned.  The integer
  234. variable must always be declared as a LongInt, regardless of its actual
  235. value, and allows signed values of -2,147,483,648 to 2,147,483,647.  Values
  236. larger or smaller than this must be of Type "Real" and entered using the
  237. EditReal() procedure with 0 decimal places declared.  If a signed value is
  238. to be entered, remember to allow an additional space for the sign in the
  239. field length declaration.
  240.  
  241.  
  242. The EditReal() procedure is declared as follows:
  243.  
  244.         EditReal(Variable Name,
  245.                    Field length,
  246.                    X position,
  247.                    Y position,
  248.                    Decimal position(s),
  249.                    Foreground color,
  250.                    Background color);
  251.  
  252. The EditReal() procedure is identical to the EditInt() procedure except for
  253. the addition of the decimal position declaration.  The variable must be
  254. declared as Type "Real" which allows for up to 11 or 12 decimal places
  255. (depending on the size of the integer range) and allows for signed values. 
  256. As above, allow spaces in the field length declaration for both the sign (if
  257. it is used) AND the implied decimal in this field.
  258.  
  259. Because numeric values are handled as strings during the actual input process,
  260. care must be made to ensure the field length is long enough for the input
  261. value.  For instance the input value "123.45" would have a field length of 6
  262. to include the implied decimal character, rather than 5 for the five numeric
  263. characters.  Note that once the integer portion of the number is filled, the
  264. cursor will automatically position itself in the decimal entry position.
  265.  
  266. Note also that only numeric characters can be entered.  Any non-numeric char-
  267. acter will cause a tone or "beep" to occur.
  268.  
  269.                              OTHER DATA TYPES
  270.  
  271. Two additional data "types" are also defined - dates and binary "choices".
  272.  
  273. The EditDate() procedure is declared as follows:
  274.  
  275.           EditDate(Variable name,
  276.                    X position,
  277.                    Y position,
  278.                    Foreground color,
  279.                    Background color);
  280.  
  281. The EditDate() procedure returns an 8-character string and MUST be initialized
  282. with the "/" characters in the appropriate position; that is, the third and
  283. sixth character of the string (for instance: Date := '  /  /';).  Because of
  284. the wide range and complexity of date handling processes, no attempt at date
  285. verification is presented in the TPU, but instead is left to the programmer/-
  286. analyst for verification on completion of the field entry.
  287.  
  288. While the EditDate() procedure was initially intended as a "MM/DD/YY" entry
  289. field, it can work equally as well as a "YY/MM/DD" or "DD/MM/YY" field,
  290. allowing for military and European date styles.  Note that extended dates
  291. such as "MM/DD/YYYY" can also be handled with "jump-over" characters in the
  292. EditString() procedure.
  293.  
  294.  
  295. The EditChoice() procedure is declared as follows:
  296.  
  297.           EditChoice(Variable name,
  298.                      X position,
  299.                      Y position,
  300.                      Choice1 character,
  301.                      Choice2 character,
  302.                      Foreground color,
  303.                      Background color);
  304.  
  305. The EditChoice() procedure returns a single byte and need not be initialized,
  306. although it is good programming practice to do so.
  307.  
  308. This procedure allows for a binary choice (one of two possibilities) such as
  309. "T/F" (true/false), "Y/N" (yes/no), "M/F" (male/female), "+/-" (plus/minus)
  310. and the like.
  311.  
  312.                            DEFAULT FIELD VALUES
  313.  
  314. In all procedures, default values may be declared by initializing the appro-
  315. priate variable equal to a specified value before the data entry is actually
  316. accomplished.  Field values may contain specific default values to minimize
  317. input operator keystrokes.  The "current date" field is a good example of a
  318. default field value that may be overwritten by the input operator.  In
  319. this case, the date field defaults to the current date string if the input
  320. operator does not choose to edit that particular field.
  321.  
  322. Field defaults help to minimize input keystrokes and entry errors by providing
  323. a given value that may be accepted or changed as required.  However, choosing
  324. specific default values may be more difficult for the programmer or analyst.
  325.  
  326. A general rule of thumb is: 1) if the default value occurs less than a third
  327. of the time, omit the default value; 2) if the default value occurs between
  328. a third and half of the time, check with the input operator or analyst to
  329. determine the "comfort level" of data entry; and 3) if the default value
  330. occurs more than half the time, include the default value in the display.
  331.  
  332. While these rules are not "hard and fast", they provide a quick method of
  333. determining default field values.  Realize also that every application has
  334. requirements and nuances that may not be readily apparent when preparing the
  335. initial prototype or design.  Further changes to the program(s) may be
  336. needed to maximize efficiency and improve input operator comfort.
  337.  
  338.                      MULTIPLE FIELD ENTRY AND EDITING
  339.  
  340. Under normal circumstances, data entry requires that more than one field be
  341. entered on the data entry screen.  Provisions must be made to correct data
  342. entry errors either when they occur or at a later time in the process, or
  343. when existing data must be updated.
  344.  
  345. Good programming practice would require both "new" data entry and "edit"
  346. procedures to allow the input operator the choice of either editing existing
  347. data or adding new data to the data file.
  348.  
  349. The program example above serves as an example of "new" data entry.  The
  350. values of Var1 and Var5 are set to null (Var1 := '';) and the values of Var2
  351. and Var3 are set to 0 and 0.0, respectively and Var4 is set to '  /  /'.  To
  352. edit an existing record, merely alter the initializing statements to equal
  353. the selected record fields (i.e., "Var1 := Rec.XVar1").
  354.  
  355. Multiple Fields
  356.  
  357. In both the new entry and edit procedures, the variables "FieldNo" and
  358. "LastField" must be initialized.  In cases where there is only one field to
  359. be entered, these variables need not be declared. (See EDITDEMO.PAS.)
  360.  
  361. "FieldNo" must be initialized to the starting field number.  Note that the
  362. starting field number need not necessarily be the first mandatory declared
  363. field number (number 1).  While the number of fields on the entry screen is
  364. essentially unlimited (2+ billion fields), the screen size itself will
  365. impose limitations on the number of fields available for use.  A caveat: the
  366. first declared field MUST be number 1!
  367.  
  368. Using both the "Repeat" and "Case" statements allow for considerable flexi-
  369. bility in changing fields:
  370.  
  371.     PgUp        goes to the first declared field. (FieldNo 1)
  372.     PgDn        goes to the last declared field.  (LastField)
  373.     Up arrow    goes to the previous field.
  374.     Dn arrow    goes to the next field.
  375.         Enter           goes to the next field.
  376.  
  377.  
  378. Field Editing
  379.  
  380. In essence, EditString() field editing is based on normal word processing
  381. and editing techniques.  They are:
  382.  
  383.         Right arrow   Moves the cursor one position right in the field.
  384.         Left arrow    Moves the cursor one position left in the field.
  385.         Home          Goes to the first character of the field.
  386.        *Del           Deletes the character directly above the cursor.
  387.        *Backspace     Deletes the character to the left of the cursor.
  388.        *Ins           Toggles between "insert" and "overwrite" modes in the
  389.                       EditString() procedure.  The default is "overwrite", but
  390.                       pressing the <Ins> key allows characters to be inserted
  391.                       and forces the following characters to fill the field.
  392.                       Note that characters forced beyond the end of the field
  393.                       are lost and that changing fields resets the toggle to
  394.                       the "overwrite" mode.
  395.  
  396.    * Note:  These keys are invalid if the EditString() field contains a
  397.             "jump-over" character to avoid deletion or misplacement of the
  398.             default character.
  399.  
  400. String and numeric editing procedures have somewhat different editing facili-
  401. ties due to the intrinsic differences in string manipulation.  Editing a
  402. numeric field requires that the <Del> key be pressed until the offending
  403. character (and the following or preceding characters) of the field are
  404. deleted and then re-entered correctly.  Toggling the decimal or "." key
  405. provides the same situation in real number editing, only from the left side
  406. of the decimal position.
  407.  
  408.                        "ESCAPING" THE DATA ENTRY PROCEDURE
  409.  
  410. Under certain circumstances, the input operator may wish to exit the data
  411. entry procedure without saving the current record.  The globally declared
  412. Boolean operator "Escape" is set to "True" if the operator presses the <Esc>
  413. key at any time during the data entry process.
  414.  
  415. NOTE: Care MUST be taken to ensure that the current record can be accepted
  416.       or discarded at the operator's discretion.  This can easily be done by
  417.       querying the operator "Save current record (Y/N)?" at the bottom of
  418.       the data entry screen when the escape key is pressed.  See the example
  419.       provided above (DATA ENTRY PROCEDURES).
  420.  
  421.  
  422.                              GENERAL COMMENTS
  423.  
  424. For some unknown reason, data input and editing is one of the least supported
  425. areas in the computer programming field and is generally relegated to various
  426. "off-the-shelf" data entry products.  While I can hardly fault the software
  427. houses for providing for this need, I am continually astounded by the various
  428. "standards" espoused for data entry.
  429.  
  430. For instance, a number of well known and highly successful "database" programs
  431. do not provide the input operator error feedback until the field entry (or
  432. the entire screen!) is completed.  Some require the deletion and total
  433. re-entry of the field, while others have such poor editing methods that it
  434. is frequently simpler and faster to delete the entire record and re-enter it
  435. as a new record.
  436.  
  437. Data entry is an innately boring and repetitious job, but it is THE MOST
  438. IMPORTANT part of data collection.  Without accurate and efficient data
  439. entry, even the best system in the world is little more than a pile of
  440. electronic equipment with some interesting (and unusable) software residing
  441. on disk or in memory.
  442.  
  443. EDITOR.TPU does not attempt to impose a "standard", but simply takes advantage
  444. of the IBM keyboard to allow the data entry operator to use it as though it
  445. were a typewriter keyboard.  We must remember that data entry operators are
  446. basically typists, and the best are VERY FAST typists.  EDITOR.TPU attempts
  447. to provide maximum programming flexibility, ease of editing and simplicity
  448. of data entry.
  449.  
  450. Speed and accuracy is the goal of data entry.  It is the responsibility of
  451. the programmer and analyst to ensure that this goal is met - not the data
  452. entry operator.  If there is EVER any doubt about the best method of data
  453. entry, ask the input operator (not necessarily the supervisor) what the
  454. easiest method would be.  Few data input operators realize they have any
  455. choices in input methods and this small effort can make you a star player in
  456. your field!
  457.  
  458. At the same time, input screen design is of major importance.  If color is
  459. used, make sure that the colors are complementary and easy on the eyes. 
  460. Bright colors and flashing characters may impress the boss, but will drive
  461. an input operator up the wall in minutes.  When in doubt, ask the input
  462. operator or, better yet, allow the operator a choice of screen colors.
  463.  
  464. Data input usually is from a paper form to an input screen.  Whenever possible,
  465. have the input screen match the paper form as closely as possible.  This
  466. allows the input operator to glance up at the screen and back to the form
  467. without losing his/her place.  If the screen design simply cannot be matched
  468. to the form, take a long look a redesigning the form.  Speed and accuracy
  469. means profits, and few managers will resist an increase in speed and accuracy
  470. over the relatively minor nuisance of redesigning a potentially confusing form.
  471.  
  472.                              REGISTRATION NOTE
  473.  
  474. EDITOR.TPU and the associated documentation and demonstration program are
  475. yours to use as you see fit.  However, if you plan to copy and distribute
  476. the program suite, please distribute ALL of it.  EDITOR.TPU is marketed on
  477. the shareware concept, "If you like it, buy it; otherwise, pass it on."
  478.  
  479. If you intend to use EDITOR.TPU in your programs (or you're already using
  480. it), please register your copy!  If you use EDITOR.TPU in only a SINGLE
  481. program, the savings in development time and effort are far more than the
  482. small $15.00 registration fee.  The registration fee is only intended to
  483. cover the cost of duplication and mailing and to determine the amount of
  484. interest in personal computer data entry methods.
  485.  
  486. As of this date, an improved BULLETPROOF version of the EDITOR.TPU is in the
  487. works.  This version may not be available on BBSs in the future; however, it
  488. WILL be available to registered users.
  489.  
  490. If you have questions or comments (or wish to register), please address them
  491. to:
  492.  
  493.                              COMPUsystems N.W.
  494.                              Attn: John Winney
  495.                         9792 Edmonds Way, Suite 226
  496.                              Edmonds, WA 98020
  497.                               (206) 774-1460
  498. C/O George Wishart [70165,460]
  499.