Tutorial Chapter 11: Master/Detail / The Orders Program orders.4gl |
This function calculates the total price for all of the items contained on a single order.
01 FUNCTION order_total(arr_length) 02 DEFINE order_total DECIMAL(9,2), 03 i, arr_length SMALLINT 04 05 LET order_total = 0 06 IF arr_length > 0 THEN 07 FOR i = 1 TO arr_length 08 IF arr_items[i].line_total IS NOT NULL THEN 09 LET order_total = order_total + arr_items[i].line_total 10 END IF 11 END FOR 12 END IF 13 14 DISPLAY BY NAME order_total 15 16 END FUNCTION