Defining the Automatic Processing Table

In filePro Plus, a processing table is a series of instructions, written by the user, which tells filePro Plus how to process or manipulate the data. There are three kinds of processing tables in filePro Plus.

Ø    “automatic” which is performed whenever a record is accessed, updated, or saved.

Ø    “input”, which manipulates data as it is being entered into a record.

Ø    “output”, which processes data during output (reports, mailing labels, etc.).

filePro Plus processing is written in a programming language similar to BASIC, but with a much wider scope of commands. The documentation that comes with filePro Plus explains the language in detail and provides examples for each command. Your fPmanual contains a lot of information that will be helpful such as the purpose and syntax of the processing commands. In summary, processing is made up of commands, punctuation, math operators, text-manipulation operators, and logic operators.

 

The Processing Table

A processing table consists of a series of elements. Each element contains a “label” area, an “if’ statement, and a “then” statement. These three pieces are called an "element". A typical element looks as follows:

 (LABEL) If: (CONDITIONAL STATEMENT GOES HERE)

Then: (ACTION STATEMENT GOES HERE)

The “label” area is used to identify a series of elements for use by the “GOTO” and “GOSUB” commands. It is also used to hold the truth or falsehood of the associated “if’ statement. Certain labels, which begin with an “@“, are used by filePro Plus to specify series of elements to be executed when a particular event occurs.

The “if” statement is evaluated each time an element is executed. If the “if’ statement is blank, then the element is evaluated as true.

The “then” statement consists of commands to be performed only if it's associated “if” statement is true. In the full filePro Plus, the number of elements allowed in one processing table is 9999. (In the filePro Plus evaluation package, the number of elements in a processing table is limited to 100.)

Syntax

The filePro Plus processing language uses quotes (“ “) around literals, which are either strings of characters (names, messages, etc.) or numbers used as constants. Examples are “smith”, "vase", "ENTER PRODUCT CODE”, "2", etc. The literal, “ “, is a special case which implies that the entire field is equal to or set equal to all blanks.

Field numbers, however, do not have quotes around them.

Variables, or “dummy fields” are named with one or two letters in filePro Plus. To be used, they must appear at least once on the left-hand side of an equation. Example: aa = 1 *”100”. This example means that dummy field, “aa", is assigned the value of the contents of field 1 multiplied by the literal, 100.

In the “Then” area dummy fields can also be given a length and edit type.

Example: va(7,.0).

In this example the dummy field “va” is given a length of 7 and an edit type of “.0” which, as you may recall, means an integer number only, no decimals.

Normally filePro Plus will reset the value in all the dummy fields when a new record is accessed. However, you can assign a dummy variable to be “global”, to retain its value in between records. The “,g” in the following example is what tells filePro Plus to make dummy field “oo” global.

Example: oo(20,allup,g).

You can write multiple action statements on the “Then” line by separating them with semicolons(;).

In addition to “real” fields (fields that exists on a file) and “dummy” fields (fields that are used temporarily for calculations), filePro Plus also includes “system-maintained” fields. System-maintained fields are listed in your fPmanual and include such things as: "the date a record was created", the "date a record was last updated" and "the record number".

We are going to define a very short automatic processing table. In this table we will demonstrate how filePro Plus can reference system-maintained and dummy fields. It also demonstrates how filePro Plus performs “date math” to calculate the number of days between dates. In a similar fashion, filePro Plus can add a number of days to a date to arrive at a new date.

Let's Get Started

1. From the main menu, select option “5 - Define Processing”.

2. For the file name, highlight or type "cust".

3. For the type of processing table, select “1 - Automatic Processing”. You should see a blank processing table that looks like figure 7-1.

NOTE: In the following processing table, and others in this tutorial, all commands and labels are shown in uppercase. Since case is not significant in filePro Plus, you may type them in upper or lowercase letters. The instructions in this tutorial have quotes around characters you are to type. However, quotes are only used with literals and are to be entered exactly as shown in the processing table.

filePro Plus has built the "If-Then" structure into its processing tables because it is the essence of all computer programming: IF some condition is true, THEN do the following action.

Each numbered section of the processing table is considered as an “element”. You should see six empty elements on your screen. Each element has a line that begins with “If:” and one that begins with “Then:” conditions which are to be tested to see if they are true or false, are typed on The “If:” line (also called the “condition” line). Instructions telling filePro Plus to do something, are typed on the “Then:” line (also called the “action” line).

 

image\fig7-1.gif

Figure 7—1. Define Processing Screen

4. On the first line, we want to test if the current record is being used to hold data. To do this, we will check if filePro Plus has placed a date in the system-maintained field “creation date”. The “creation date” field is referenced by using the code @cd. Press <RETURN> once to move the cursor into the condition area. Type @cd ne " " and then press <RETURN>. Note that “ne” means “not equal to”.

5. To reference the system-maintained “today’s date” field we use @td. Now, on the action line type: aa(5, .O)=@td-@cd and then press <RETURN>.

This action line can be read as meaning: place into dummy field “aa” who’s length is 5 and as an integer, the difference (in days) between the date this record was created and today’s date.

For the second element, we will be referencing the date this record was last updated. The system-maintained field that contains "the date this record was last updated" is: @ud.

6. Move to the “If’ area on element 2 by pressing <RETURN>. Type: @ud ne "" and press <RETURN>

7. On the action line type: ab(5, .O) = @td - @ud

 Your two elements of processing should agree with figure 7-2.

image\fig7-2.gif

Figure 7-2

NOTE: In order for this processing table to work properly, make sure that your computer system date is properly set.

Let’s review what this processing table does. It does mathematical calculations using dates. filePro Plus has system-maintained fields which hold data that is generated by the computer, such as time, dates, record number, etc. (see the Quick Reference Guide). filePro Plus processing can do math with the values in the system-maintained fields.

Element 1 means that if system-maintained field “@cd” (creation date) has something in it, then the dummy field “aa” will contain the difference (number of days) between the value in “@td” (today’s date) and “@cd” (creation date). You probably recall that dummy field “aa” was labeled “Days on File” on the customer data-entry screen. This simply tells the user how long this customer has been on file.

“If: On the “If:” line “@cd ne “ ““ means that if the field is not equal (“ne”) to nothing (“ “), meaning if it is equal to something (it has something in it).

“aa(5,.0)” is the instruction to filePro Plus to define a variable, or dummy field, “aa” with a length of 5 and an edit type of “integer”, a whole number.

Element 2 of the processing table deals with the system-maintained field “@ud” (date of last update of the current record). If @UD has been set, then dummy field “ab”, contains the difference between today’s date and the date of last update. As you probably remember, the dummy field, “ab”, was labeled “Days Since Last Update” on the customer data-entry screen.

If the statements in the condition lines where not true, that is, the system- maintained fields were empty, the statements on the action lines would not be performed. This is appropriate since only an unused record would have these fields empty.

8. Since this is an “automatic” processing table, these computations are performed as soon as the record is displayed, when the user goes into update mode, and when the record is saved. The dummy fields on the data-entry screen will display the results of these computations.

9. Save the table by pressing <ESC>. In response to the syntax check prompt, press <Y>. The syntax checker will locate and help you correct syntactical or typographical errors.

10. At the “Hardcopy (YISIN)” prompt, press <RETURN>. Remember that pressing <RETURN> in response to a Yes/No prompt is the same as a “No”.

NOTE: Pressing “Y” prints a copy of the entire processing table. If the processing table is empty (no commands listed), pressing “Y” returns you to the previous menu. Pressing “S” prints the entire processing table omitting the lines separating the numbered elements. Pressing “N” or <RETURN> returns you to the previous menu.

11 At the “Cross Reference Hardcopy?” prompt, press <RETURN>. The cross reference listing of a processing table gives you lots of information that can be useful in correcting lengthy processing tables.

Do not leave Define Processing at this time. We will be using it in the next lesson.