Returns a TRUE value if the current iteration of a DO, FOR EACH, or REPEAT . . . BREAK block is the first iteration of that block.
FIRST ( break-group )The r-first.p procedure displays the order number, OrderLines on the Order, the extended price of each OrderLine, and a total order value for each Order record:
DEFINE VARIABLE order-value AS DECIMAL NO-UNDO LABEL "Order-value".FOR EACH Order NO-LOCK:DISPLAY Order.OrderNum.FOR EACH OrderLine OF Order BREAK BY OrderLine.Qty * OrderLine.Price:IF FIRST(OrderLine.Qty * OrderLine.Price) THENorder-value = 0.order-value = order-value + OrderLine.Qty * OrderLine.Price.DISPLAY OrderLine.LineNum OrderLine.ItemNumOrderLine.Qty * OrderLine.Price LABEL "Extended-price".END.DISPLAY order-value.END.Because the inner FOR EACH block iterates until the AVM reads all the order-lines, the procedure must set the order-value variable to 0 each time a new order is used in that block. The FIRST function uses the (qty * price) expression as the break-group to keep track of whether or not the current iteration is the first iteration of the FOR EACH block.
© 2012 Progress Software Corporation and/or its subsidiaries or affiliates. |