The Invoice File Input Processing Table

Before we show you the processing table (program) that makes our tutorial database so easy, convenient, and useful, we have reproduced the structures of all the files here, so that you can identify the various fields and better understand what the processing is doing with them:

Customer File. “cust”

 

1

customer number

4

 

 

2

last name

15

uplow

 

3

first name

15

uplow

 

4

address

15

allup

 

5

city

15

allup

 

8

state

2

state

 

7

zip

10

zip

 

8

‘LTD sales

9

.2

 

 

 

 

 

Product File. “nrod”

 

1

Product code

3

allup

 

2

Description

15

uplow

 

3

Price

7

.2

 

4

Quantity on hand

3

.0

 

5

Quantity sold

8

.0

 

6

Unit cost

9

.4

 

7

Value on hand

9

.2

 

 

State Tax File. “sttax”

 

1

state

2

state

 

2

tax rate

5

rate

 

 

 

 

 

State Names File. “states”

1

Abbreviation

2

state

2

Name

20

Allup

3

Capital city

25

Allup

 

Invoice File "invc"

1

Customer number

4

 

2

Invoice number

5

.0

3

Invoice date

8

mdy/

4

customer last name

15

uplow

5

customer first name

15

uplow

6

state tax

5

.2

7

billing address

15

allup

8

city

15

allup

9

state

2

state

10

zip

10

zip

11

A1) product code

3

allup

12

A1)

3

allup

13

A1)

3

allup

14

A1)

3

allup

15

A2) quantity

3

.0

16

A2)

3

.0

17

A2)

3

.0

18

A2)

3

.0

19

A3) description

15

uplow

20

A3)

15

uplow

21

A3)

15

uplow

22

A3)

15

uplow

23

A4) unit price

7

.2

24

A4)

7

.2

25

A4)

7

.2

26

A4)

7

.2

27

A5) total cost

10

.2

28

A5)

10

.2

29

A5)

10

.2

30

A5)

10

.2

31

subtotal

10

.2

32

state tax

7

.2

33

total amount due

10

.2

 

Overview

The input processing table for the invoice file contains the “behind the scenes” programming that makes entering data in the invoice file so easy and productive (the customer and product files are updated automatically) As you probably recall, these are the main features:

 

1. The customer file “year—to—date sales” field is updated automatically.

2. The product file “quantity on hand” and “quantity sold” fields are updated automatically.

3. When you enter a valid customer number, the customer name, address, and tax rate fields are filled in automatically.

4. If you don’t have a valid customer number, you can see a browse lookup window containing existing customer numbers and names, and you can fill in the customer number, name, address, and tax rate fields simply by selecting a record from the list.

5. If you don’t have a valid product code, you can see a browse lookup window containing product codes, descriptions, and prices, and you can fill in the product code, description, price fields, simply be selecting a record from the list.

6. You can add new products to the product file via the invoice data-entry screen; you can enter the product code, description, price, and quantity on hand; a new record is created in the product file.

7. You can change the line item entries in the invoice record, whether it is a new invoice or previously saved, and the customer and product files are updated accordingly.

8. If you delete an invoice record, the customer and product files are updated accordingly.

9. Subtotals, tax, and total amount are calculated for you, and updated as soon as you make any changes.

 

filePro Plus Processing

To review, filePro Plus processing is written in a programming language similar to BASIC, but with many powerful commands specific to filePro Plus operations. The documentation that comes with filePro Plus documents the language completely. The Quick Reference Guide, included in the filePro Plus package, lists the purpose and syntax of the processing commands.

 

A “lookup”, to which you were introduced in the input processing table for the customer file, is a “connection” made to another file for purposes of bringing in data from the file or “posting” data to the file.

 

The Invoice File Input Processing Table

You will find the complete invoice file input processing table reproduced below. Following it is an element-by-element explanation of the program.

Also, processing tables contain comments to help programmers and others read and understand what the program does. Anything on a processing line that is to the right of an apostrophe (‘) is a comment to filePro Plus.

The explanation of the processing is written in the same order as the numbered elements in the table. Whenever the program “branches”, (using the GOSUB or GOTO commands) you should, too, to see what the subroutine does. When the subroutine ends and processing returns to the element where the subroutine was called, you should, too. This is probably the best way to try to understand a pro-gram.

Syntax

filePro Plus processing language uses quotes (““) around literals, which are either strings of characters (names, messages, contents of fields, etc.) or numbers used as constants, by themselves, or in expressions. Examples are “smith”, “vase”, “EN-TER PRODUCT CODE”, “2”,etc.

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

Variables, or “dummy fields” are named with one or two letters in filePro Plus. Dummy fields can be given a length and edit type. Example: va(7,.0). In the exam-pie the dummy field “va” is given a length of “7” and an edit type of “.0” which means integer numbers only, no decimals. If more than one programming statement is on a single “Then:” line, the statements are separated by a semicolon (;).

NOTE: For maximum legibility, we have used uppercase characters to show filePro Plus commands; for labels, we have used an initial capital letter. In your processing tables you may disregard upper and lowercase except for literals and, under UNIX/XENIX, for screens and file names.

 

The processing table

 

Jun 19, 2000 16:14 File Name: INVC Page 1

Processing: Input

 

1 ------- - - - - - - - - - - - - - - - -

If:

Then: '---------ROUTINE FOR WHEN THE USER SAVES A RECORD---------------

2 ------- - - - - - - - - - - - - - - - -

If: 3="" ' if invoice date is blank (empty)

Then: 3=@td ' assign today's date as invoice date

3 ------- - - - - - - - - - - - - - - - -

If: 2="" ' if invoice number is blank (field 2)

Then: gosub getinvn; 3=@td ' get the next number

4 ------- - - - - - - - - - - - - - - - -

If:

Then: show "POSTING"; gosub post; show ""; end ' post product usage

5 ------- - - - - - - - - - - - - - - - -

@wef1 If:

Then: '--THIS CHECKS IF THE USER IS UPDATING AN ALREADY POSTED RECORD--

6 ------- - - - - - - - - - - - - - - - -

If: sw ne "" ' if already unposted keep BREAK off

Then: break off

7 ------- - - - - - - - - - - - - - - - -

If: 2="" or sw ne ""

Then: end ' do nothing if new record or already unposted

8 ------- - - - - - - - - - - - - - - - -

If:

Then: break off; show "UNPOSTING"; gosub unpost; sw="x"; show ""

9 ------- - - - - - - - - - - - - - - - -

If:

Then: end

10 ------- - - - - - - - - - - - - - - - -

@wlf1 If: '----------WHEN LEAVING THE CUSTOMER NUMBER FIELD----------------

Then: '----------------- GET THE CUSTOMER RECORD ----------------------

11 ------- - - - - - - - - - - - - - - - -

If: 1 eq ""

Then: goto error

12 ------- - - - - - - - - - - - - - - - -

If:

Then: lookup cust k=1 i=b -nx

13 ------- - - - - - - - - - - - - - - - -

If: cust

Then: goto custok ' customer # is OK

14 ------- - - - - - - - - - - - - - - - -

error If:

Then: beep ' customer # is NG

15 ------- - - - - - - - - - - - - - - - -

If:

Then: show "PICK A CUSTOMER OR PRESS \r A \r TO ADD A NEW CUSTOMER"

16 ------- - - - - - - - - - - - - - - - -

If: ' pop up browse help window

Then: lookup inp = cust k=1 i=a -ng b="(brw=12 xkey=a pop=1 fill=asc)

*1 *3 <2 "

17 ------- - - - - - - - - - - - - - - - -

If: @bk eq "a"

Then: gosub addcust;display;goto @wlf1

18 ------- - - - - - - - - - - - - - - - -

If: 'erases the earlier help message

Then: show ""

19 ------- - - - - - - - - - - - - - - - -

If: not inp ' if user presses break return to field 1

Then: screen ,1

20 ------- - - - - - - - - - - - - - - - -

If: ' user chose a customer #... store and process

Then: 1=inp(1); display; goto @wlf1

 

 

Jun 19, 2000 16:14 File Name: INVC Page 2

Processing: Input

 

21 ------- - - - - - - - - - - - - - - - -

custok If:

Then: 4=cust(2); 5=cust(3); 7=cust(4); 8=cust(5); 9=cust(6); 10=cust(7)

22 ------- - - - - - - - - - - - - - - - -

If:

Then: '----------------- GET THE TAX RATE TABLE -----------------------

23 ------- - - - - - - - - - - - - - - - -

If:

Then: lookup tax = sttax k=9 i=a -bx

24 ------- - - - - - - - - - - - - - - - -

If: not tax

Then: beep; msgbox "TAX RATE FOR:" < 9 < "NOT FOUND"

25 ------- - - - - - - - - - - - - - - - -

If:

Then: 6=tax(2); gosub calc; end

26 ------- - - - - - - - - - - - - - - - -

@wefa1 If:

Then: '------ROUTINES FOR GETTING AN ITEM FROM THE PRODUCT FILE--------

27 ------- - - - - - - - - - - - - - - - -

If: ' when entering any product code field show a help message

Then: show "ENTER ITEM CODE or \r NEW \r TO ADD A NEW ITEM"

28 ------- - - - - - - - - - - - - - - - -

If: sw ne "" ' keep break off if updating posted record

Then: break off

29 ------- - - - - - - - - - - - - - - - -

If:

Then: end

30 ------- - - - - - - - - - - - - - - - -

@wlfa1 If: ' when leaving a product code field clear the help message

Then: show ""

31 ------- - - - - - - - - - - - - - - - -

If: a1="" ' no product # entered...clear line and calculate totals

Then: a2=""; a3=""; a4=""; a5=""; gosub calc; end

32 ------- - - - - - - - - - - - - - - - -

If: a1="new" ' user wants to add a new product to file

Then: gosub addprod; goto @wlfa1

33 ------- - - - - - - - - - - - - - - - -

If:

Then: lookup prod k=a1 i=a -nx

34 ------- - - - - - - - - - - - - - - - -

If: prod ' product code is OK

Then: goto okprod

35 ------- - - - - - - - - - - - - - - - -

If: ' product # is NG... pop up browse help window

Then: lookup inp2 = prod k=a1 i=a -nx b="*1 *2"

36 ------- - - - - - - - - - - - - - - - -

If: not inp2 ' user pressed BREAK... return to product code field

Then: screen ,a1

37 ------- - - - - - - - - - - - - - - - -

If: ' user chose a product code... store and process

Then: a1=inp2(1); display; goto @wlfa1

38 ------- - - - - - - - - - - - - - - - -

okprod If:

Then: a3=prod(2); a4=prod(3); gosub calc

39 ------- - - - - - - - - - - - - - - - -

If:

Then: end

40 ------- - - - - - - - - - - - - - - - -

@wlfa2 If: '--------------CHECK PRODUCT QUANTITY ON HAND--------------------

Then:

 

 

 

Jun 19, 2000 16:14 File Name: INVC Page 3

Processing: Input

 

41 ------- - - - - - - - - - - - - - - - -

If: a2="" or a2="0" ' no quantity entered

Then: a2="1"; display

42 ------- - - - - - - - - - - - - - - - -

If:

Then: lookup prod k=a1 i=a -ex

43 ------- - - - - - - - - - - - - - - - -

outs If: prod(4) lt "1"

Then: beep; show "@ PRODUCT"<A1<"IS OUT OF STOCK... ON HAND=" < prod(4)

44 ------- - - - - - - - - - - - - - - - -

If: outs

Then: goto outs2

45 ------- - - - - - - - - - - - - - - - -

If: prod(4)-a2 lt "0"

Then: beep; show "@ CAN ONLY FILL PARTIAL ORDER... ON HAND=" < prod(4)

46 ------- - - - - - - - - - - - - - - - -

outs2 If:

Then: gosub calc

47 ------- - - - - - - - - - - - - - - - -

If:

Then: end

48 ------- - - - - - - - - - - - - - - - -

@wefa2 If: a1="" ' if no product # clear rest of line and skip fields

Then: a2=""; a3=""; a4=""; a5=""; gosub calc; skip

49 ------- - - - - - - - - - - - - - - - -

If:

Then: end

50 ------- - - - - - - - - - - - - - - - -

calc If:

Then: '------CALCULATE EXTENTIONS, SUBTOTAL, TAX, and GRAND TOTAL------

51 ------- - - - - - - - - - - - - - - - -

If:

Then: 27=15*23; 28=16*24; 29=17*25; 30=18*26; 31=27+28+29+30

52 ------- - - - - - - - - - - - - - - - -

If:

Then: 32=31*6; 33=31+32; display; return

53 ------- - - - - - - - - - - - - - - - -

unpost If:

Then: '-------subroutine to UNPOST PREVIOUS ITEMS and QUANTITIES-------

54 ------- - - - - - - - - - - - - - - - -

If: ' point arrays "item" & "quant" to 1st product & quantity fields

Then: dim item(4):11; dim quant(4):15; ix(3,.0)="1"

55 ------- - - - - - - - - - - - - - - - -

unpostl If: item(ix)="" ' if no product #... skip it

Then: goto bumpix

56 ------- - - - - - - - - - - - - - - - -

If: ' set ky to product code

Then: ky=item(ix)

57 ------- - - - - - - - - - - - - - - - -

If: ' get product record

Then: lookup prod k=ky i=a -ex

58 ------- - - - - - - - - - - - - - - - -

If: ' unpost usage

Then: prod(4)=prod(4)+quant(ix); prod(5)=prod(5)-quant(ix)

59 ------- - - - - - - - - - - - - - - - -

bumpix If: ix lt "4" ' point to next product code field

Then: ix=ix+"1"; goto unpostl

60 ------- - - - - - - - - - - - - - - - -

If:

Then: lookup cust k=1 i=b -ex

 

 

 

Jun 19, 2000 16:14 File Name: INVC Page 4

Processing: Input

 

61 ------- - - - - - - - - - - - - - - - -

If:

Then: cust(8)=cust(8)-33; return

62 ------- - - - - - - - - - - - - - - - -

post If:

Then: '----------subroutine to POST PRODUCT USAGE----------------------

63 ------- - - - - - - - - - - - - - - - -

If: ' set counter ix to "1"

Then: ix="1"

64 ------- - - - - - - - - - - - - - - - -

postl If: item(ix)="" ' if no product #... skip

Then: goto bumpix2

65 ------- - - - - - - - - - - - - - - - -

If:

Then: ky=item(ix)

66 ------- - - - - - - - - - - - - - - - -

If:

Then: lookup prod k=ky i=a -ex

67 ------- - - - - - - - - - - - - - - - -

If:

Then: prod(4)=prod(4)-quant(ix); prod(5)=prod(5)+quant(ix)

68 ------- - - - - - - - - - - - - - - - -

bumpix2 If: ix lt "4"

Then: ix=ix+"1"; goto postl

69 ------- - - - - - - - - - - - - - - - -

If:

Then: lookup cust k=1 i=b -ex

70 ------- - - - - - - - - - - - - - - - -

If:

Then: cust(8)=cust(8)+33; return

71 ------- - - - - - - - - - - - - - - - -

getinvn If:

Then: '------subroutine to GET THE NEXT HIGHER INVOICE NUMBER----------

72 ------- - - - - - - - - - - - - - - - -

If:

Then: ky="99999" ' set ky to the highest possible invoice #

73 ------- - - - - - - - - - - - - - - - -

If:

Then: lookup invc k=ky i=a -bl

74 ------- - - - - - - - - - - - - - - - -

If: ' add 1 to invoice #

Then: 2=invc(2)+"1"; display; return

75 ------- - - - - - - - - - - - - - - - -

addprod If:

Then: '-------------subroutine to ADD A NEW PRODUCT--------------------

76 ------- - - - - - - - - - - - - - - - -

If: ' ask for new product #

Then: cls("22"); input ("23","30") in(3,allup) "ENTER PRODUCT # >"

77 ------- - - - - - - - - - - - - - - - -

If: in=""

Then: goto addprod

78 ------- - - - - - - - - - - - - - - - -

If: ' check if product already on file

Then: lookup prod k=in i=a -nx

79 ------- - - - - - - - - - - - - - - - -

If: prod ' if already on file use it

Then: a1=in; return

80 ------- - - - - - - - - - - - - - - - -

If: 'clears earlier message

Then: show ""

 

 

 

Jun 19, 2000 16:14 File Name: INVC Page 5

Processing: Input

 

81 ------- - - - - - - - - - - - - - - - -

If: 'shows a help message for popup

Then: show "ENTER INFORMATION THEN HIT \r ESC \r TO RECORD"

82 ------- - - - - - - - - - - - - - - - -

If:

Then: lookup new=prod r=free -e

83 ------- - - - - - - - - - - - - - - - -

If:

Then: new(1)=in

84 ------- - - - - - - - - - - - - - - - -

If:

Then: popup update new,0

85 ------- - - - - - - - - - - - - - - - -

If:

Then: a1=in;clearp;display; return

86 ------- - - - - - - - - - - - - - - - -

@keyd If:

Then: '----------------ROUTINE FOR WHEN USER DELETES A RECORD----------

87 ------- - - - - - - - - - - - - - - - -

If: @cd="" 'if records already deleted (creation date blank)

Then: end 'do nothing

88 ------- - - - - - - - - - - - - - - - -

If:

Then: cls("22"); input("23","20") yn(1,yesno) "DELETE THIS RECORD.. ARE Y

OU SURE"<yn ; cls("22")

89 ------- - - - - - - - - - - - - - - - -

If: yn="y"

Then: show "UNPOSTING"; gosub unpost; delete; show "";end

90 ------- - - - - - - - - - - - - - - - -

addcust If: 'rountine to add a new customer

Then: lookup add=cust r=free -ex

91 ------- - - - - - - - - - - - - - - - -

If:

Then: popup update add,1

92 ------- - - - - - - - - - - - - - - - -

If:

Then: 1=add(1);4=add(2);5=add(3);7=add(4);8=add(5);9=add(6);10=add(7)

93 ------- - - - - - - - - - - - - - - - -

If:

Then: clearp;return

 

The written program starts with programming for the last thing the user does, and that is: saving the record by pressing <ESC>.

The following is a detail description of what is going on the processing table.

Elements 1-4

Element 1 Here is a comment. The apostrophe tells filePro Plus that everything that follows on this line is commentary and is not for execution.

Element 2  If “invc” field 3 (“invoice date”) is empty (equal to nothing), then fill it with the filePro Plus system-maintained field, “@TD” (“today’s date”).

Element 3  If field 2 (“invoice number”) in the invoice file is empty (equals nothing) then processing goes to a “subroutine”(“GOSUB Getinvn”). A subroutine is a section of the processing table that performs the same task several times during a program run). The label (name) of the subroutine is “Getinvn” which means get an invoice number. “Getinvn”‘ begins in element 71 (which is labeled “Getinvn”) and ends in element 74 with the command “RETURN”, which returns processing to the statement following the GOSUB  command that sent processing to “Getinvn” in the first place.

Element 4 The SHOW command is used by filePro Plus to show a message to the user. The message will be centered and shown in line 23 of your screen unless specific line and column coordinates are given. The statement in element 4 means display on the screen the literal that follows in quotes, which, in this case, is “POSTING”.

The next statement in element 4 says go to the subroutine labeled “Post” (elements 62—70) This subroutine updates the product and customer files. When the processing returns from the “Post” subroutine, the SHOW command, now used with nothing in quotes (““) tells filePro Plus to replace the previous message, “POSTING”, with nothing, thereby, erasing it.

The END command tells filePro Plus to stop processing here since there is no more work to be done when the user saves the record.

@wef1

Elements 5—9  The label, “@WEF1”, tells .filePro Plus to execute this section of processing When the user Enters Field 1 (which happens to be the “customer number” field).

Element 5 The comment describes the function of this particular when-processing. The processing checks to see if the record being updated has already posted data to the “cast” and “prod” files. If the data have been posted, that is the “If:” tests in elements 6 and 7 are not true, then the processing “falls through” elements 6 and 7 to element 8, where the <BREAK> key is turned off, the message, “UNPOSTING” is displayed, and the processing is sent to a subroutine called “Unpost” (elements 53-61) where the data posted to “prod” and “cust” are taken back, and the “prod” and “cust” files are adjusted accordingly.

Element 6 Variable “sw” is used as a switch. When it has some value, that is, it is NE (not equal) to nothing, this means the “prod” and “cust” file have been “unposted”. The “sw” variable is given a value of “x” when unposting has been performed (element 8). Unposting will undo the updating that was done when the record was last saved. The <BREAK> key is turned off, because, if <CTRL> <BREAK> is pressed, the user gets out of update mode with the data from the record unposted. The “prod” and “cust” files would no longer be accurate.

Element 7 The statement on the condition line means: if the “invoice number” field is empty, or the variable “sw” is not empty, (that means the record is a brand new record or one that has already been unposted), then there is nothing further for the program to do here, so the processing is ended.

Element 8 If the “If:” test in element 7 fails, that is, it is not true, and, therefore, the unposting has not been done, processing is sent to the unposting subroutine, “Unpost”. But first, the message “UNPOSTING” is SHOWn on the screen. When processing returns from the subroutine, “sw” variable is given a value (“x”). The message is erased by the SHOW statement (show nothing).

Element 9 This ends the when-processing.

@wlfl

Elements 10—25  This when—processing occurs When the user Leaves Field 1.

Element 10 Comment describes the following when-processing.

Element 11 If field 1 was left blank, go to the error routine (elements 14 - 20) which show a browse window of available customers or allow you to add a new customer.

Element 12 A lookup is made to the “cast” file. The key field is field 1, “customer number” in the “invc” file (“k = 1”), the index to use in the “cust” file is “B” (“i = b”), which was built on the “customer number” field. “-n” means that filePro Plus will do nothing if the lookup fails. “x” means that the contents of the field in the current record and the contents of the field in the lookup file must match exactly or the lookup fails.

Element 13 If the lookup is successful (“If: cast”) then the processing
goes to a section of the processing table labeled “CustOK”

 

(elements 21—25).

Element 14 If the lookup is not successful, the processing ignores element 13, does not go to “CustOK”. Instead, it “falls through” to element 14 where the BEEP command sounds the computer’s beeper once, to alert the user to the lookup failure.

Element 15 A help message is displayed. The text between each “\r” is  displayed in reverse video.

Element 16 Now a browse lookup is executed to help the user, since the customer number in field 1 didn’t match any in the “cast” file. This time a lookup name, “inp” is assigned to the file name “cast” in the lookup statement. In a later statement, “inp” will be used in place of “cast”. The “g” in “-ng” specifies that the record highlighted in the browse lookup window will be the next one with the key field contents greater than the value the user put into the key field in the current record.

 The “brw = 12” means start the browse window in row 12.

 The “xkey = A” means that the “A” key can be used to exit.The “pop = 1” means that when you press “V.”, Screen 1 will pop up. The “fill = asc” means the customers will come up in ascending order. *3<2” specifies the position of the fields in the browse lookup window. Remember the “s” indicates a field and the”<” tells filePro Plus to “push left” the next field to within one space of the previous field.

Element 17 If at the browse window you press <A> to add the @BK = A will be true and is sent to a subroutine to add a customer (elements 90—93). The display would redraw the screen, and the goto @WLF1 will continue the processing.

Element 18 The message from element 15 is erased by the SHOW statement.

Element 19 If the browse lookup fails (the user would have to press <CTRL> <BREAK> for this to happen), the cursor re-turns to the data-entry screen, field 1, “customer number”, and the “when leaving field” processing is ended.

Element 20 If the browse lookup was successful, the user has selected a particular customer, this element copies the data into the “customer number” field. The DISPLAY command displays the results of processing on the screen. In this instance, the “customer number” field will be changed to show the number selected by the user, and the processing returns to the label, “@WLF1”.

custok

Element 21 Now that there is a valid number in the “customer number” field, the other customer information fields can be filled in. Working from the lookup created in element 12, the data from the “cust” file is copied, field by field, into the “invc” fields: “invc” field 4 gets the data from “cast” field 2, and so on.

Element 22 The comment marks the section of processing code that locks up the tax rate from the “sttax” file.

Element 23 Lookup to the “sttax” file, the key field in the invoice is field 9, “State”, the index to use in the “sttax” file is “A” (which is built on the “state” field). If the lookup fails, fill the field with blanks (“-b”). And, finally, the key fields must match exactly (“x”).

Element 24 If the lookup fails, beep once, display a MSGBOX on the screen. The “<9” in the middle of the text cause the con-tents of field 9 (state) to be displayed there.

Element 25 If the lookup is successful, element 24 is ignored, and the contents of the state field (field 2, “tax rate”) in the “sttax” file is used to fill in field 6, “Tax Rate” in the invoice record. Then, processing is sent to a subroutine called “Calc” (elements 50-52), where the various line item totals, subtotals, tax and total amounts are calculated and displayed in the appropriate fields on the screen. When processing returns from the “Calc” subroutine, the “@WLF1” processing ends.

@wefa1

Elements 26—29 This when—processing is one of the routines for filling in the product information fields in the invoice. Here, the label refers not to a particular field, but, to any of the fields in the associated fields, “Al)”.

Element 26 Comment.

Element 27 When the user enters any “Product Code” field, a message is displayed. The text between the two “\r”s is in reverse video.

Element 28  If variable “sw” is not equal to nothing (the record has already been un-posted) turn off the <BREAK> key.

Element 29 End this when-processing.

@wlfa1

Elements 30—39 This when—processing fills in the product description and price, and recalculates the totals, when the user leaves the product code” field (associated field “Al”). If the product code in the field is not valid, a browse lookup window containing valid product codes and descriptions are displayed. The user can then select the product code. The “product code” field is filled in, and then the “description” and “price” fields are filled in.

Element 30 The message displayed by element 27 is erased.

Element 31 If no product code has been entered in the “product code” field, make the other fields on the line blank, the totals are recalculated, and the processing ends.

Element 32 If the user has entered the word, “new”, in the “product code field, processing goes to subroutine “AddProd” (elements 75—85), where he or she can enter a new product in the invoice and in the “prod” file, as well. When the processing comes back, it goes to “@WLFA1” (element 30). Element 33 Lookup to the “prod” file. The key field in the “invc” file is al (“product code”). The index in the “prod” file to use is “A” (“product code”). If the lookup fails, do nothing (“n”). The contents of the key fields must match exactly (“x”).

Element 34 If the lookup is successful, processing goes to the section labeled “OKProd” (element 38).

Element 35 If the lookup fails, a browse lookup is made to the “prod” file. The lookup name is “inp2”. The key field in the “invc” file is “al”, the index to use in the “prod” file is “A”. If the lookup fails, do nothing (“-n”). Look for an exact match (“x”). The rest of the line is the formatting of the browse window.

Element 36 If the browse lookup fails (the user would have to press <CTRL> <BREAK>, or the “prod” file would have to be empty for this to happen), restore the cursor to the appropriate “product code” field (“al”), and end this when-processing.

Element 37 The user has selected a record from the browse lookup window, and the data is copied into the “product code” field. The results are displayed on the screen; processing goes to “@WLFA1” (elements 30-39).

okprod 

Element 38  This OKProd” section of processing uses the previous lookup to copy data from the “prod” file to the associated “description” and “price” fields in the current record. It then re—calculates all of the totals.

Element 39 The when-processing ends here.

@wlfa2

Elements 40—47 This when-processing checks the quantity entered in the “quantity” field against the quantity on hand in the “prod” file and reports to the user if there is either none on hand or not enough to fill the order completely.

Element 40 Comment.

Element 41 If the “Quantity” field contains nothing or zero, a “1” is as-signed by processing, and the change is DISPLAYed on the screen.

Element 42 A lookup to the “prod” file is done. The key field in the “invc” file is “al”. The index in the “prod” file to use is “A”. The “-e” tells filePro Plus to display a standard error message if the lookup fails.

outs

Element 43 This section (elements 43 - 45), labeled “Outs” does the following: If the number in the “prod” field 4 (“quantity on hand”) is less than “1” (LT “1”), then the computer beeps once, and SHOWs the message. The “Al” in the message will actually be the contents of the “Product Code” field when the message is shown. The “prod(4)” in the message is the contents of “prod” file, field 4. The “<“ is a “push-left” indicator, which tells filePro Plus to move the contents of the field to the left, to within one space of the field or text on the left.

Element 44 If “Outs”, above, is true (the “If:” part of element 43 is true) processing goes to label, “Outs2”, on element 46.

Element 45 If the contents of “prod” field 4 (“quantity on hand”) minus the contents of “invc” field a2 (“quantity”) is less than zero (a negative number), then the computer beeps once, and the message is displayed.

outs2

Element 46 The processing calls the subroutine “Calc” to recalculate the totals.

Element 47 When the processing comes back from “Calc”, it ends here for this when—processing section.

@wefa2

Elements 48-49 This section of processing is performed when the user moves the cursor into field A2, the product quantity.

Element 48  If the “product code” field (field Al) is blank, then clear the rest of the line, recalculate the totals, and skip this field.

Elements 49 If the processing falls through to this line (the “product code” field is not blank) then end this section here.

NOTE: The rest of the processing table (elements 50-95) contains the subroutines that have been referenced by the first section of processing (elements 1—49).

calc

Elements 50 - 52 This is subroutine “Calc”. It multiplies and adds field contents to get the correct amounts. For each line of product information, it multiplies the “quantity” field by the “price" field to get an amount for the “total cost” field. Then it adds the “total cost” fields, multiplies that amount by the tax rate, adds the tax amount to the subtotal to get the “total amount due” for the invoice. Then the results of these calculations are DISPLAYed on the screen.

unpost

Elements 53-61 The “Unpost” subroutine is first called all the way back in element 8. It “undoes” the “posting” (updating) that was done to the “prod” and “cast” files when the record was last saved. It assumes that the user has entered update mode on the invoice record to change the product information. Therefore, the old data has to be “unposted” in preparation for posting the revised data.

Element 53 Comment.

Element 54 Two “arrays" are created to streamline the unpost operation. An array is a “structure” for holding data. It can have an unlimited number of elements or compartments for holding the data. You can assign these compartments to hold data from specific fields in a file. Arrays enable you to handle many repetitive operations involving field contents with a minimum of processing code. In this processing table the arrays “item” and “quant” are created with the DIM (dimension) command. Array “item” has 4 elements. The first element is “mapped” (linked) to field 11 (“Product Code). Therefore, “item” element 2 will be mapped to field 12; element 3 mapped to field 13; and element 4 to field 14. The “quant” array is mapped to the “quantity” fields, starting with field 15.

 The array elements now hold the data from the fields they are mapped to.

 Elements of an array are referred to by the array name and the element number or “subscript”. (example: item(”3”). A variable (“dummy field”) “ix” (length: 3; edit: .0) will be used in place of literal subscripts when referring to the array elements.

 The arrays are DIMensioned and the variable “ix” is given an initial value of “1”.

Unpost1

Element 55 If the current element of array “item” (field 11, “product code”) contains nothing, then go to the section of processing labeled “Bumpix”. (We know that item(ix) is pointing to field 11 because variable “ix” has just been set to “1”.)

Element 56 The variable “ky” is set to item(ix), the product code. This is so that “Icy” can serve as the key field in the lookup which follows.

Element 57 Lookup to the “prod” file. “ky” is the key field. The index in the “prod” file to use is “A” (built on the “product code” field). If the lookup fails, show a standard error message (“-e”). Look for an exact match of key field contents (“x”).

Element 58 With the lookup established, the data in the array elements is used to adjust the quantities in the “prod” file. The value held in the “quant” array element (taken from “invc” “quantity” field) is added to the “prod” field 4 (“quantity on hand”). This is, of course, the opposite of what was done when the record was last saved; the quantity from the in-voice was subtracted from the quantity on hand in the “prod” file.

 The same kind of thing is done with “prod” field 5, “quantity sold”. Since we are undoing the posting that was done when the record was last saved, we subtract from the quantity sold.

bumpix

Element 59 To repeat this operation for the next item in the invoice: first, the number (subscript) of the element used is checked to see that is not the last element (4). If it isn’t, the variable “ix” is bumped up “1’,, so that its value is “2”. The next time ‘lx is used as a subscript in an array it will designate the element as the second element in the array. With this done, the processing is sent back to “Unpost1” for the next pass.

Element 60 A lookup to the “cast” file. The key field is “invc” field 1 (“customer number”). The index in the “cust” file to use is “B” (built on the “customer number” field). If the lookup fails, a standard error message is displayed (“-e”). Look for an exact match of the key field contents (“x’).

Element 61 The contents of field 33 (“total amount due”) is subtracted from the contents of field 8 (“YTD sales”) in the “cast” file. This “unposts” field 8 in the “cast” file. Processing returns from this subroutine to element 8, from where it was called. This subroutine does the opposite of the previous one (see elements 55-61) This subroutine “posts” data to the “prod” and “cast” files.

getinvn

Elements 71—74 This subroutine provides a new invoice number for the current record. It performs a lookup to the “invc” file to find  the last invoice number used. Then it increments the number by one and uses it for the current invoice number.

Element 71 Comment.

Element 72 Set variable, “Icy”, to the highest possible invoice number (“99999”).

Element 73 Lookup to the “invc” file. The key field is variable “Icy”. The index to use is “A”. If the lookup fails, the field is to be blanked (“-b”). If an exact match for the invoice number is not found, then the lookup will return the record with the next lowest invoice number (“I”).

Element 74 Field 2 in the current record (“invoice number”) is set equal to field 2 in the lookup record plus “1”. The results are DISPLAYed on the screen, and the processing is RETURNed to element 3.

Addprod

Elements 75 - 85 This subroutine enables the user to add a new product record to the “prod” file. It is called from element 32.

Element 75 Comment

Element 76 The screen is cleared to the bottom, starting at line 22. User INPUT is expected. The prompt “ENTER PRODUCT CODE” is displayed starting at line 23, column 30. The input from the user will be held in variable “in” (length of 3,edit: allup)

Element 77 If variable “in” contains nothing, processing goes back up to element 75. Element 78. A lookup is made to the “prod” file to see if the product code the user entered is already in use. The key field for the lookup into the “prod” file is dummy field “in”. The index to use in the “prod” file is “A” (built on the product code field). If the lookup fails, filePro Plus does nothing. The lookup is for an exact match of the key field contents (“x”).

Element 79 If the lookup is successful, “invc” field “al” gets the contents of dummy field “in” (which is the code input by the user), and the processing returns to the element that called it.

Element 80 The SHOW statement clears the previous input message.

Element 81 Shows a help message for the popup window.

Element 82 A “free record” lookup is made to the “prod” file. A “free record” lookup is used to post data to an empty (“free”) record in the lookup file. This is the means by which the new product record is entered in the “prod” file. “-e" means that if the lookup fails, filePro Plus displays a standard error message.

Element 83 The dummy field which was filled in earlier, is copied to the new record in the product file.

Element 84 A popup window with a screen from the product file is displayed and is in update mode. Field 1 contains data.

Element 85 “invc” field “al” picks up the data from variable “in” (product code). The screen is brought up to date with the CLEARP and DISPLAY commands. Processing returns to element 32, and then to “@WLFA1” (element 30) where the new product code in field “al” will make the lookup in element 33 successful. The product description and price fields will be filled in (element 38) from the “prod” file.

NOTE: When-processing can also be used to intercept a key that the user presses, while displaying a record and before entering update mode. In the following example we want to unpost a record before the user deletes it. The format of the label that tells filePro Plus to intercept a particular key is: @KEYx Where “x” is any single character.

@keyd

Elements 86—89 This when—processing happens when the “D” key is pressed by the user to delete the current record.

Element 86 Comment.

 

Element 87 The processing here checks to see if the record has already been deleted by testing the system-maintained creation date field (@CD) to see if it is empty. If it is, nothing is done, and the processing ENDs.

Element 88 The screen is cleared to the bottom starting at line 22. IN-PUT from the keyboard is expected. The input message starts on line 23, column 20. It requires a yes or no answer, which will be put into variable “yn”. After the user types in the answer, the screen is cleared again from line 22 down.

Element 89 If variable “yn” contains a “y”, meaning yes, the user does want to delete the record, then the “UNPOSTING” message is SHOWn, and processing calls the unposting subroutine, “Unpost”. When processing returns from “Unpost”, the record is DELETEd, the message is erased and the @KEY processing ends.

Addcust

Elements 90-93 This subroutine enables the user to add a new customer to the customer file. It is called from element 17.

Element 90  The lookup is performed to open a free record in the customer file. The popup update command will popup a screen in Update mode from the lookup file (in this case Screen 1).

Element 92 The fields are now copied from the record we just added into the record we’re on in the invc file.

Element 93 The CLEARP command, clears the popup window. We are then returned to Element 17.