Function order_total
This function calculates the total price for all of the items contained on a single order.
Function order_total (orders.4gl):
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
Note:
- Line
07
thru11
contain aFOR
loop adding the values ofline_total
from each item in the program arrayarr_items
, to calculate the total price of the order and store it in the variableorder_total
. - Line
14
displays the value oforder_total
on the form.