home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Best Objectech Shareware Selections
/
UNTITLED.iso
/
boss
/
data
/
dbas
/
002
/
readme1.doc
< prev
next >
Wrap
Text File
|
1990-08-18
|
10KB
|
252 lines
This application demonstrates how to develop a multi-relational data
base system for order processing. Look up CUSTOMER info from one file &
part numbers as well as costs and descriptions from a separate PART file.
WAMPUM automatically enters today's date as the ORDERDT as well as a
unique ORDERNO. WAMPUM also computes the total price of the order.
To start the application, do the following:
1. Add \WAMPUM to your DOS PATH by typing: PATH=\WAMPUM
2. Set up the CLIPPER environment by typing: SET CLIPPER=V010
3. Change to the sample application directory: CD \WAMPUM\SAMPLE1
4. Run the WAMPUM program by typing: WAMPUM VOODOO
Here is the structure of the ORDERS file which permits customers to
order up to three items in any quantity up to 99.
NUM FLD NAME TYPE FLD LEN FLD DEC
--- ---------- ---- --------- -------
1 CUSTOMER C 20 0
2 ADDRESS C 30 0
3 CITY C 15 0
4 STATE C 15 0
5 ZIP C 10 0
6 ORDERDT D 8 0
7 PARTNO_1 C 10 0
8 DESCRIP_1 C 10 0
9 PRICE_1 N 10 2
10 QUAN_1 N 2 0
11 PARTNO_2 C 10 0
12 DESCRIP_2 C 10 0
13 PRICE_2 N 10 2
14 QUAN_2 N 2 0
15 PARTNO_3 C 10 0
16 DESCRIP_3 C 10 0
17 PRICE_3 N 10 2
18 QUAN_3 N 2 0
19 ORDER_TOT N 11 2
20 ORDERNO N 5 0
When a new order is placed by choosing A - Add a Record, a blank data
entry screen appears. Rather than having to type a customer name over
and over as new orders are placed, these are entered in a separate
customer file. To call up the name and address of an existing
customer, simply press ALT-9 while in ADD MODE. If you want to see the
whole table of customers alphabetically, press <ENTER> when prompted
for the customer to find. Then highlight the desired customer and
press <ENTER>. WAMPUM will automatically inserts the customer info.
To order a part, we will use the same sort of approach. Rather than
entering the name of the part, part number, and price, we will simply
look them up from an existing PART table (another dBASE data base!).
For the first part, press ALT-1 and then <ENTER> if you don't know the
part name. Highlight the desired part and press <ENTER>. WAMPUM will
insert the part information into fields 7, 8, and 9. You will have to
fill in the quantity. ALT-2 and ALT-3 do this for two more part orders.
Automatically calculate the order date as TODAY (if you left this field
blank) and WAMPUM will assign this order a UNIQUE order number, too.
All this magic is contained in two files. Error checking and field
calculations including the unique order number are entered into the
EDIT.DBF file. Table lookup is set up in the TABLE.DBF file.
An explanation of the various entries in the EDIT and TABLE files
follows.
Edit Checks File Examples
Record No. 1 *** WAMPUM BEGINNERS ALWAYS FORGET TO DO THIS! ***
EDITTEST: ORDERS
ERRMSG:
Comments: The first record must contain the UPPER CASE name of the
data base which will be used in conjunction with the EDIT.DBF file.
Record No. 2
EDITTEST: empty(flddata[1])
ERRMSG: Customer name is a required entry.
Comments: The EDITTEST field defines an error condition. In this
case, we are checking for a blank FIRST field which is the CUSTOMER
field. If this error condition exists in either ADD or EDIT mode, the
ERRMSG typed above will be displayed. This prevents entry of a blank
record.
Record No. 3
EDITTEST: =empty(flddata[6]) .and. helpcode=1
ERRMSG: 6,date()
Comments: Here we are computing the order date if it is blank in ADD
mode only. HELPCODE=1 means the user chose option 1 from the WAMPUM
Main Menu. Empty(FLDDATA[6]) means the order date field is blank on
the data entry screen. Refer to the CREATING CALCULATED FIELDS
section of the User's Guide for info on the ERRMSG entries. In short,
the 6 says compute the value for FLDDATA[6] and the computed value is
DATE() which in dBASE lingo is TODAY.
Record No. 4
EDITTEST: flddata[6]>date()
ERRMSG: Order date in the future is not permitted.
Comments: Here we are making sure that the order date is NOT in the
future. Note that we are defining WHEN an error occurs, in short when
the FLDDATA[6] field is GREATER THAN today's date. If the error
occurs, then the ERRMSG entered above will be displayed.
Record No. 5
EDITTEST: EMPTY(FLDDATA[10]) .AND. .NOT. EMPTY(FLDDATA[7])
ERRMSG: Quantity for Part 1 cannot be 0.
Comments: We want to make sure that if a PART NUMBER is entered for
ITEM 1, that a quantity ordered is also entered.
Record No. 6
EDITTEST: !!.NOT. EMPTY(FLDDATA[10]) .and. helpcode=1
ERRMSG: 7,PART,PARTNO,ONHAND,ONHAND-FLDDATA[10]
Comments: One of WAMPUM's major enhancements is demonstrated here. We
are changing the value of the ONHAND count in a related data base when
the user places a new order (ADD mode) and the ITEM 1 quantity is
greater than 0. In English, the ERRMSG means the following: open the
PART data base with the PARTNO index. Look up the PARTNO contained in
FLDDATA[7]. Then decrement the existing ONHAND count by the amount
contained in FLDDATA[10]. The same logic is used for PARTS 2 and 3.
Record No. 11 simply tallies the TOTAL ORDER PRICE.
EDITTEST: =.T.
ERRMSG: 19,FLDDATA[18]*FLDDATA[17]+FLDDATA[14]*FLDDATA[13] . . .
Record No. 12 demonstrates looking up a unique order number. WAMPUM
will automatically increment the UNIQUE number in UNIQUE.DBF and stuff
the result in FLDDATA[20], the order number field, in ADD mode only.
EDITTEST: #HELPCODE=1 .and. empty(FLDDATA[20])
ERRMSG: 20,UNIQUE
Table Lookup Examples
Record No. 1
FILE: PART INDEX: PART
PROMPT Enter part name or <ENTER> for all: DISPLAY1 PART
DISPLAY2 PARTNO DISPLAY3 ONHAND DISPLAY4 COST
DISPLAY5 PRICE DISPLAY6 DISPLAY7
DISPLAY8 DISPLAY9 FLDDATA1 7 FLDFILE1 PARTNO
FLDDATA2 8 FLDFILE2 PART FLDDATA3 9 FLDFILE3 PRICE
Comments: Record 1 in TABLE sets up a TABLE LOOKUP SYSTEM for hot-key
ALT-1. The file and index to be used both are named PART. If the
prompt field is filled in, WAMPUM will prompt the user for whatever you
say. This obviously must match the index selected. If PROMPT is left
blank, the entire table will be displayed without prompting the user.
The field names in DISPLAY1 thru DISPLAY9 tell WAMPUM which fields from
the PART data base to display for the user. If all of these are left
blank, then every field in the data base will be displayed in the field
order specified when the file was created. FLDDATA1 through 9 tell
WAMPUM the numbers of the fields in the PRIMARY data base to be
calculated. FLDFILE1 thru 9 tell WAMPUM what data from the PART file
is to be stuffed into the FLDDATA elements specified. In this record,
we are telling WAMPUM to stuff FLDDATA[7] with the PARTNO of the record
chosen from the table, FLDDATA[8] is to be stuffed with the PART name,
and FLDDATA[9] is to be stuffed with the PRICE of the item.
Records 2 and 3 do the same thing for the second and third part entries
in the ORDER data entry form.
Record No. 9
FILE: CUSTOMER INDEX: CUSTOMER
PROMPT Enter customer's last name: DISPLAY1
DISPLAY2 DISPLAY3 DISPLAY4
DISPLAY5 DISPLAY6 DISPLAY7
DISPLAY8 DISPLAY9 FLDDATA1 1 FLDFILE1 CUSTOMER
FLDDATA2 2 FLDFILE2