home *** CD-ROM | disk | FTP | other *** search
/ Acorn RISC PD-CD 1 / Acorn RISC PD-CD 1.iso / utilities / powerbase / pbasedoc / validation < prev   
Encoding:
Text File  |  1994-01-05  |  13.1 KB  |  243 lines

  1.                              Data Input Validation
  2.                              =====================
  3. Type validation
  4. ===============
  5. By this term we mean the exercising of control over what characters a field
  6. will accept. RISC OS provides the means to allow writable icons to accept
  7. only certain characters, or ranges of characters, and reject others. The
  8. disallowed characters are simply ignored so that attempts to type them have
  9. no effect.
  10.  
  11. If you open Powerbase's own application directory (SHIFT/double-click) you
  12. will find a file called 'ValStrings'. You are recommended not to alter this
  13. file unless you understand exactly what you are doing and, if you do so, to
  14. keep a copy of the original. Examining it, however, can give you an insight
  15. into the validation process. Look, for example, at the entry "03 Number".
  16. This refers to field type 3 (numeric). The line below is the validation
  17. string of the writable icon which makes up a numeric field. It looks like
  18. this:-
  19.                         Pptr_write,4,4;A0-9.+\-
  20.  
  21. The intial 'P' is a command and signifies "pointer". 'ptr_write' is the name
  22. of the sprite used to represent the mouse pointer when it is over this type
  23. (and many other types) of field. You will have noticed that the usual RISC
  24. OS arrow changes to a blue vertical bar, somewhat resembling the caret, when
  25. over a writable field. '4,4' specifies the "active point" of the pointer.
  26. The next character is a semicolon which indicates that a new command
  27. follows.
  28.  
  29. The 'A' which comes next is the command "allow" and is the part of the
  30. validation string which especially concerns us. It determines what
  31. characters the field will allow you to type. In this case they are the
  32. numerals 0-9, the decimal point and the plus and minus signs. Why the back-
  33. slash before the latter? Because '-' is a special character in an icon
  34. validation string (used, as in this case, to specify a range of characters)
  35. and so are the semicolon, tilde (~) and the backslash itself. To include any
  36. of these four characters in the validation string you must precede it with a
  37. backslash.
  38.  
  39. A couple of further examples should be sufficient. "01 Alphanumeric" uses
  40. the same pointer type but the characters accepted are <space> (immediately
  41. after the 'A' for "allow"), the upper-case letters A-Z, the lower-case
  42. letters a-z, the numerals 0-9, some common punctuation and the "half"
  43. character. You might want to add to this list.  "06 Calculated" uses a
  44. different pointer sprite (ptr_calc, which resembles a pocket calculator) and
  45. has no "allow" command at all: it doesn't need one because you can't type
  46. into this type of field, whose value is calculated from other fields.
  47.  
  48. Table validation
  49. ================
  50. This level of validation only comes into effect after entering data in a
  51. field which is linked to a validation table. Such fields are recognizable by
  52. having their text dark green instead of black. When you click the mouse over
  53. a new field or type RETURN, the linked validation table is scanned to see
  54. whether what you entered in the field occurs in the table. If it doesn't
  55. then Powerbase will restore the previous contents of the field and print an
  56. error message.
  57.  
  58. Validation tables should be used whenever the contents of a field have to
  59. conform to certain "values". A manufacturing company will have a product
  60. code for every item which it makes and a database of customers which the
  61. firm supplies will make use of such codes to identify the items. It is
  62. essential that whoever enters the data is prevented from accidentally typing
  63. a spurious code. By linking the appropriate field to a validation table
  64. containing all the valid codes such mistakes can be prevented. Moreover, the
  65. validation table can also contain other data about the products, such as a
  66. name and a brief description, and lists can be printed in which this more
  67. understandable data appears instead of the cryptic codes. Up to nine items
  68. of data could be associated with each product code.
  69.  
  70. The F.E. college database referred to in 'BrowseEdit' ("Using more than one
  71. subfile") makes extensive use of validation tables for subjects, courses,
  72. tutors and schools of origin. Not only does this trap typing errors but the
  73. data entry is greatly speeded up when one can type 'ELL' instead of 'English
  74. Language and Literature', yet have the latter printed out in full on a list
  75. or a timetable if one wishes.
  76.  
  77. A further option with validation tables is to have Powerbase replace the
  78. typed-in code with a longer, more readable, form immediately on entry.
  79. Provided the substitute data will fit in the field the replacement occurs
  80. when you type RETURN or click the mouse in another field. If the replacement
  81. is too long then the typed-in data will be unchanged.
  82.  
  83. The maximum number of validation tables is 20 and is determined by the text
  84. file 'Config' within the 'Resources' subdirectory in the Powerbase directory.
  85.  
  86. Creating a validation table
  87. ===========================
  88. Choose 'Create table' from the 'Validation' submenu. Give the table a
  89. suitable name and enter the number of rows required. This will be the
  90. maximum number of values the table can contain. Always be generous in your
  91. estimates; tables can't be extended later. The next item required is the
  92. highest column number in the table. A maximum of 10 columns, with numbering
  93. from 0-9, is allowed. 
  94.  
  95. The most common situation is to have two columns. The first holds the short
  96. code which specifies what may be typed into the linked record field. The
  97. second is an expansion or explanation of the former. Define the maximum
  98. length of each field in the table and give each one a heading. Don't forget
  99. that the heading has to fit within whatever column width the field length
  100. will allow. There will only be single spaces between the columns.
  101.  
  102. When you are satisfied with the data click 'OK' and the table will be
  103. created in memory. It is not saved on disc at this stage.  You may enter
  104. data into it now or later. Entries may be freely altered and overwritten but
  105. do not forget to save the table whenever changes have been made.
  106.  
  107. Linking tables to fields
  108. ========================
  109. To link a validation table to a field the table must be in memory . Click
  110. MENU over the required data field and follow the 'Field' submenu, choosing 
  111. the 'Link to table' option.
  112.  
  113. A pair of "bump icons" permits you to cycle through the tables in memory. A 
  114. menu, displayed by clicking SELECT or MENU over the right-pointing arrow to
  115. the right of the table name, provides an alternative way of choosing a
  116. table. When you have the name of the required one displayed choose the
  117. column of the table to which the field is to be linked. It is recommended
  118. that column 0 should normally provide the link (and therefore contain the
  119. data items which may be actually entered on the records) and this is set by
  120. default. You may, however, link to any column in the table and a second pair
  121. of "bump icons" allows you to cycle throught the column numbers.
  122.  
  123. If you want the "replace on entry" option described previously then select
  124. the option switch for this. A third set of "bump icons" then becomes active,
  125. allowing you to choose which column of the table will replace the data which
  126. you type in. In such cases both the entries in the validation list proper
  127. and those in the replacement list are considered equally valid and either
  128. may be typed. e.g. in the case quoted above for the F.E. college database
  129. you could actually type in 'English Language and Literature' if you wished,
  130. instead of just 'ELL'. Powerbase would accept either, but the former will
  131. obviously take much longer to enter and you are far more likely to make a
  132. mistake (in which case Powerbase would object). 
  133.  
  134. Select the switch 'Link to table' and click on 'OK'. You will now see that
  135. the foreground colour of the linked field has changed from black to green.
  136. Place the caret in the field and click on 'List values' on the keypad. The
  137. validation table should be displayed.
  138.  
  139. Displaying linked data
  140. ======================
  141. The final entry on the 'Validation' submenu is 'Show relations'. Powerbase
  142. makes no claim to be anything but a flat-file database, but effective use of
  143. validation tables does give it some of the advantages normally to be found
  144. only in a relational database. If you choose the 'Show relations' entry
  145. (so that it becomes ticked) you will find that clicking the over a data
  146. field which is linked to a validation table causes a small window to appear
  147. to the right of the keypad. This window lists all the data which is on the
  148. same row of the validation table as the linked item. As you edit the record,
  149. moving from field to field, this window is constantly updated. It disappears
  150. when the caret is in a non-linked field.
  151.  
  152. You can also bring up this window (whether 'Show relations' is ticked or
  153. not) by double-clicking with SELECT on a linked field - very handy if coded
  154. data is being used and you encounter a code you've never met before.
  155.  
  156. Displaying validation tables
  157. ============================
  158. When a table is linked to a field in the database record it may be displayed
  159. by placing the caret in the linked field and clicking on the keypad
  160. button 'List values' (keystroke equivalent f8). Alternatively, any table
  161. present in memory, whether linked to a data field or not, may be displayed
  162. by selecting it from the 'Display table' sub-menu (off the 'Validation'
  163. sub-menu). Clicking MENU over the table then offers a menu with entries
  164. enabling you to clear, save, print or sort the table.
  165.  
  166. The validation table menu
  167. =========================
  168. Clear
  169. -----
  170. Removes all data from the table, leaving it blank. Since wiping out a table
  171. in this way is pretty drastic (and irrevocable) you will need 'Manager'
  172. level rights to do it, otherwise 'Clear' is shaded. Even so you are asked to
  173. confirm the operation before it actually takes place. When you close a
  174. database all the validation tables in memory are written to the disc so you
  175. will over-write your disc copy with the blank table. 
  176.  
  177. Save
  178. ----
  179. This leads to a 'Save' box in which the default pathname points to a
  180. directory called 'ValTables' inside the database application directory.
  181. Since that's where Powerbase expects to find the tables for a database you
  182. should normally accept this pathname by clicking on 'OK' or typing RETURN.
  183. Only if you are transferring tables from one database to another should you
  184. need to drag the icon to a filer window. All validation tables in memory
  185. are, in any case, saved to the 'ValTables' directory when you close the
  186. database or quit Powerbase and you can also make this happen at any time by
  187. clicking on 'Force update' on the keypad.
  188.  
  189. Print
  190. -----
  191. Printing out the contents of a validation table (as opposed to printing a
  192. report containing data from a validation table) is done via this menu
  193. choice. The output appears in a window from which it may be saved as a text
  194. file (see 'Printing' - Output destination). 
  195.  
  196. Sort
  197. ----
  198. This will sort the table on the first column.
  199.  
  200. Loading validation tables
  201. =========================
  202. Once a table is linked to a data field it will be automatically loaded when
  203. the database is opened. If not yet linked, however, the table won't be in
  204. memory unless you have just created it. To load the table choose 'Show table
  205. files' from the 'Validation' submenu. The contents of the 'ValTables'
  206. directory will be displayed and the required tables can dragged onto the
  207. record window (or simply double-clicked). As each table is dropped it will
  208. be displayed. N.B. Only one table at a time may be actually displayed.
  209.  
  210. There may be times when the user wishes to use a validation table to hold
  211. some data, but doesn't wish to use it to validate input into a field or to
  212. link it to a field at all. How does one make sure the required table gets
  213. loaded? It is always possible to load a validation table once the database
  214. is open by using the procedure described in the previous paragraph, but
  215. there's a more elegant solution. By adding a "!" character to the end of the
  216. table's name you will cause Powerbase to load it whether any field is linked
  217. to it or not.
  218.  
  219. Including validation table data in printouts
  220. ============================================
  221. Validation tables are commonly used to allow short codes to be entered in
  222. records but with a link to a more descriptive entry in another column of the
  223. table.  If this is all you require then always put the data which makes up
  224. the actual validation list, i.e. the items which are allowed in the fields
  225. of the main record, into the first column of the table and set the link 
  226. from the record field to this column (column 0). The more detailed
  227. "expanded" entry should then go in column 1. Printing with the 'Expand'
  228. switch in the 'Print options' window selected  will then print the column 1
  229. instead of the column 0 entry.
  230.  
  231. You can, however, include data from other columns of a table by displaying
  232. the table  and clicking in the required columns with ADJUST, exactly like
  233. selecting main record fields for printing (see 'Printing'). It is immaterial
  234. which row you click on: only the column matters and the highlighting to show
  235. which columns are selected always appears in the first row. The columns
  236. selected in all tables are saved as part of a print selection and may
  237. therefore be retrieved for future use. As well as highlighting the required
  238. columns you will also need to select the 'Expand' switch as described above.
  239. Printed reports will then include all the data from the highlighted columns.
  240.  
  241.  
  242.  
  243.