Defining A User Edit for the State Tax File

Notice that we used the edit type “rate” for the “tax rate” field. This edit is not supplied by filePro Plus and has to be created before records can be added to the “sttax” file. The ability for the person who creates an application to define new field types is one of filePro Plus’s most powerful features. It allows you, the designer, to insure that the data entered by the user conforms to the proper specifications. In this example, we want to insure that the data entered in the tax rate field is numeric and falls within the range of .0 through .9999.

 

1. From the filePro Plus main menu, select option “4 - Define Edits”. The file selection window appears. At the top of the list of file names in the window is the word, “[GLOBAL].” If you select it, you will get the “global edits” table.

Global edits, are the specifications for field types that can be used by any file you create. filePro Plus comes with a number of common field types already defined in the global table. You can modify or add to the global table.

File Edits are the specifications for field types that can only be used by the file for which they are defined. If you have two edits with the same name, one in the global table and one in the file table, the one in the file table overrides the one in the global table. Also, edits may refer to other edits within the same table, and file edits can refer to global edits. Before we go on, there are two simple rules you need to remember when defining an edit:

a. If a data-entry field is left blank by the user, the edit type is not applied. To insure that this does not happen, you would define the field on the data-entry screen with the “must-fill” field indicator of "%". This means that the user must enter some data in the field, and therefore, the edit will be applied.

b. If the field type specification contains an “either or” situation, the longer of the choices must appear first in the edit definition (the choice that is matching on the most characters).

2. Let’s discuss our tax rate edit for a moment. There are two ways a user might enter a tax rate in the “sttax” file; as a percent (5.5) or as a tax rate multiplier (.055). We’re going to define an edit that ensures that the data entered in the tax rate field is in the tax-rate-multiplier form.

Now we’re ready to define the “rate” edit for the “sttax” file.

3. Press <4> “Define Edits” with the file selection window displayed, highlight or type: "sttax" and press <RETURN>.

4. At the “New Dictionary” question, press <Y>.

Our “rate” edit tells filePro Plus to accept only data that starts with a decimal point and is followed by any number of characters that will pass the edit named “number”. (See your Quick Reference Guide or press the help key, <F1O>, for the punctuation, logic operators, and modifiers used to define user edits).

This is the Define User Edits screen for file edits in update mode:

image\fig11-1.gif

Figure 11-1. Define User Edits Screen (Update Mode)

5. In the “Name” column, type the name: rate and press <RETURN>.

6. In the “Edit” column, type: {number}

The braces ({}) tell filePro Plus to accept any number of characters that con-form to the format enclosed by the braces. In this case, the edit requires a decimal point followed by any number of characters that pass the edit named “number”. Now we have to define the edit named “number”.

7. Move to the second line under the “name” column and type : " number". Press <RETURN>.

8. Now type: "0"-"9" This edit means: accept any single character within the range of zero through nine.

9. Press <ESC> to save the edits.

10.  Another feature of filePro Plus allows you to test your edits before you use them in your application. Press <T> to test an edit. For the edit name, type: rate. Press <RETURN>.

11.  For the length, type: "5" and press <RETURN>.

12. At “Enter Field” prompt type: "1.000". A message is displayed, “Edit Failed At Cursor Position”. Your edit worked. This invalid entry was rejected.

13 Now, clear the field by using the <SPACE BAR> to fill the field with blank spaces. The message disappears; press <RETURN> to put the cursor back in the test field. Type:" .la". Press <RETURN>.

A message is displayed, “Edit Failed At Cursor Position”, now with the cursor positioned over the “a”, indicating the specific character rejected.

14. Again, clear the field with the space bar press <RETURN> and type: ".055". Press <RETURN>.

The cursor moves to the right indicating that the data you entered passed the edit and is ready for the next field entry.

15. At this point we want to add some flexibility to the edit by allowing a leading zero (0) to be entered with the tax rate value, then delete the zero. Also we want the results to be right justified, that is, we want filePro Plus to insert leading spaces to cause the right-most digit entered to be the right-most character in the field. Press <CTRL> <BREAK> twice to leave the test mode and then press <U> for update mode.

16. Press <RETURN> to move to the “edit” area of “rate” and press <Fl> or <INS> ten times. Now type the following: \ [!‘0“!]

The backslash (“s) tells filePro Plus to right-justify the data entered.

17. By adding [!“0”!] to the “rate” edit we are instructing filePro Plus to delete the zero if it is the first character in the field before the decimal point. The “[]“ tell filePro Plus that the enclosed entry is optional and the “!!“ tell filePro Plus to delete the character that is enclosed. Press <ESC> to record the table. Press <T> to go back into test mode.

18. Type in the edit name: "rate".

19 Now type: "0.25". Press <RETURN>. This time the data passes the edit and the leading zero is deleted by filePro Plus.

20. Next, we’re going to use filePro Plus to make data-entry even easier. You are going to learn how to create an edit that will translate a code into a value. Leave test mode by pressing <CTRL> <C> or <CTRL> <BREAK> twice. Then press <U> to enter update mode.

21. Assume that you want to use a code “1” that will represent “.075” and a code “2” that will represent “.055”. Press <RETURN> to move to the “Edit” area and press <F7> to move to the end of the data entered. Press the <SPACEBAR> once, and now type the “or” operator, “I “, (the broken vertical line) and press the <SPACEBAR>. Continue by typing the following: !“1”! <.075> I 12”! <“.055”> and press <RETURN>

22 Type in a length of “6”, (to accommodate the leading zero) and press <RETURN>. This tells filePro Plus that if the data entered is simply a “1”, delete it and replace it with “.075”. If the data entered is a “2”, delete it and replace it with“.055”. Save the edit by pressing <ESC> and, as before, go back into test mode,

Enter a length of 6, and enter a “1” (without quotes). Clear the field with the <SPACE BAR> and try a “2”.

23 Edits can also be used to automatically display a help message at the bottom of the screen during data-entry. To implement this, go back into update mode (press <CTRL><C> twice), change the name “rate” to “rate2”, press <F3> (to insert a line), and type in a new edit name, “rate”. In the edit area for “rate” type the following: ‘ENTER: .nnnn, 1 for .075, 2 for .055’ rate2

24 Type the apostrophes as shown. Press <ESC> to save the edit.

The completed edit table should look like figure 11-2.

image\fig11-2.gif

Figure 11-2. Define User Edits Screen (“sttax” file)

25 Press <X> to exit the screen.

The “rate” edit now tells filePro Plus to display the message within the apostrophes, and apply the “rate2” edit. (Edit messages are not displayed in testing.) Let’s look at what we’ve accomplished in the last few minutes to make data-entry more accurate.

Ø    We created our own edit for the rate field.

Ø    We filtered out non-numeric characters.

Ø    We right—justified the data that was entered.

Ø    We made the edit more flexible by allowing the user to enter a leading zero (0.055) and had filePro Plus eliminate it automatically.

Ø    Then we added the ability to use codes (1 or 2) to represent some common tax rates this eliminated extra typing.

Ø    Finally we added a message to inform the user how to use these codes.

And remember, we were able to test each edit to assure it was doing what we wanted it to do, as soon as we entered it.

The “rate2” edit tells filePro Plus to right—justify, \, optionally, [>, delete, !!, a leading zero, accept a decimal point followed by any number of characters, {}, that pass the edit type, “number”. Or, j, delete, !!, a leading one and replace it,<>,with .075. Or, |, delete,!!, a leading two and replace it, < >, with .055.

The “number” edit tells filePro Plus to accept any single digit within the range of " 0-9".

Now we have a “rate” edit which will insure that the data entered in the tax rate field of the “sttax” file will be numerical, and in the form of a 1—4 place decimal. This eliminates confusion for the user in entering or viewing tax rate data in the “sttax” file. Also, it simplifies the handling of two common tax rates.

Creating data edits in filePro Plus was simple. Many of the edits you will need are already supplied. Any special edits you require can be easily created by you. But these file edits only work on a specific file. Now we’re going to briefly look at filePro Plus’s Global Edits - a capability that you can use throughout your application.

A number of global edits have been supplied by filePro Plus. You can modify these edits or you can add new edits of your own. Let’s take a moment to look at the supplied Global Edits.

26. From the main menu, select option “4 - Define Edits” or press <F> to select the file when viewing the Define Edits screen.

27. From the file selection window, select “[GLOBAL].”

28. There are over 100 Global Edits provided by filePro Plus. One we will look at now is the “CHEQUE” edit. Let’s test the edit to see how it works. First press the <PgDn> key once to bring the "cheque" edit into view. Press <T>.

29. For the edit name, type: "cheque". Press <RETURN>.

30. For the field length, type: "150"

31. Now type: "12345.67" This represents the amount of the check. Press <RETURN>. You should now see in the field: *** twelve thousand three hundred forty—five and 67/100 dollars ***

This is just an example of the power of filePro Plus available to you. You might want to try other values to the “cheque” edit or test some of the other supplied edits, such as; “zip”, “state”, or “phone”.

32. When you are ready to leave the Define Edits program, press <CTRL> <C> or <CTRL> <BREAK> twice, then press <X> to return to the main menu.