home *** CD-ROM | disk | FTP | other *** search
- *****************************************************************
- * Test program for COMPUTE function - FILE T_COMPUT.PRG
- *****************************************************************
-
- * Copyright(c) 1991 -- James Occhiogrosso
-
- * Computes, displays and validates totals for line items
-
- # include 'inkey.ch'
-
- LOCAL keypress := price1 := price2 := quantity1 := quantity2 := 0
-
- #ifdef DEBUG
- DEVELOP()
- #endif
-
- INITGLOBAL()
- SETCOLOR(colstd)
- CLEAR
-
- DO WHILE keypress != K_ESC
-
- * Get quantity and price of each item. Update and
- * validate the total with each entry.
-
- @ 5, 15 GET quantity1 PICTURE '999' VALID ;
- COMPUTE(quantity1 * price1, 5, 30, ;
- "99999.99", "CHKTOTAL", colhelp1)
-
- @ 5, 22 GET price1 PICTURE '99.99' VALID ;
- COMPUTE(quantity1 * price1, 5, 30, ;
- "99999.99", "CHKTOTAL", colhelp1)
-
- @ 6, 15 GET quantity2 PICTURE '999' VALID ;
- COMPUTE(quantity2 * price2, 6, 30, ;
- "99999.99", "CHKTOTAL", colhelp1)
-
- @ 6, 22 GET price2 PICTURE '99.99' VALID ;
- COMPUTE(quantity2 * price2, 6, 30, ;
- "99999.99", "CHKTOTAL", colhelp1)
-
- @ 7, 15 TO 7, 37 DOUBLE
- READ
-
- ENDDO
- RETURN
-
-
- *****************************************************************
- FUNCTION CHKTOTAL (ret_value)
- *****************************************************************
- * Sample user defined function called by COMPUTE
-
- * Displays and validates total each time data
- * is entered into one of four quantity and price fields.
-
- LOCAL old_color := ''
-
- LOCAL tot_amt := (quantity1 * price1) + (quantity2 * price2)
-
- IF tot_amt > 99999.99
-
- * Amount exceeds specified limit
- ERRORBEEP()
- CENTERON(MAXROW(), 'Entry too large. ' + hitanykey)
-
- * Display asterisks in total field
- old_color = SETCOLOR(colbarhi)
- @ 8, 30 SAY '*****.**'
- SETCOLOR(old_color)
-
- * Wait for operator
- INKEY(0)
-
- * Clear totals area and return to pending GET
- @ 8, 30 SAY SPACE(8)
- @ MAXROW(), 0
- ret_value = .F.
-
- ELSE
- * Total is within defined limits
- @ 8, 30 SAY tot_amt PICTURE '99999.99'
-
- ENDIF
-
- RETURN ret_value
-
-