LAST-OF( ) method Returns TRUE if the current iteration of the query predicate FOR EACH . . . BREAK BY. . . is the last iteration for a new break group. Return type: LOGICAL Applies to: Query object handle Syntax LAST-OF ( level ) level An integer expression that indicates a BREAK BY group, where 0 is the entire query, 1 is the first BREAK BY, 2 is the second BREAK BY, and so on. The following example shows how the LAST-OF( ) method is used to identify the last record of a break group: DEFINE QUERY qCustomer FOR Customer SCROLLING. QUERY qCustomer:QUERY-PREPARE("FOR EACH Customer WHERE Customer.CustNum > 50 BREAK BY Customer.Country BY Customer.Comments"). QUERY qCustomer:QUERY-OPEN. REPEAT WITH TITLE "Customers Break By Country and Comments": GET NEXT qCustomer. IF NOT AVAILABLE Customer THEN LEAVE. DISPLAY Customer.Country FORMAT "x(10)" Customer.Comments FORMAT "x(20)" QUERY qCustomer:FIRST-OF(0) LABEL "First" QUERY qCustomer:LAST-OF(0) LABEL "Last" QUERY qCustomer:FIRST-OF(1) LABEL "First Country" QUERY qCustomer:LAST-OF(1) LABEL "Last Country" QUERY qCustomer:FIRST-OF(2) LABEL "First Company" QUERY qCustomer:LAST-OF(2) LABEL "Last Company". END. See also: FIRST-OF( ) method, OPEN QUERY statement, QUERY-PREPARE( ) method
LAST-OF ( level )
DEFINE QUERY qCustomer FOR Customer SCROLLING.
QUERY qCustomer:QUERY-PREPARE("FOR EACH Customer WHERE Customer.CustNum > 50
BREAK BY Customer.Country BY Customer.Comments").
QUERY qCustomer:QUERY-OPEN.
REPEAT WITH TITLE "Customers Break By Country and Comments":
GET NEXT qCustomer.
IF NOT AVAILABLE Customer THEN LEAVE.
DISPLAY
Customer.Country FORMAT "x(10)"
Customer.Comments FORMAT "x(20)"
QUERY qCustomer:FIRST-OF(0) LABEL "First"
QUERY qCustomer:LAST-OF(0) LABEL "Last"
QUERY qCustomer:FIRST-OF(1) LABEL "First Country"
QUERY qCustomer:LAST-OF(1) LABEL "Last Country"
QUERY qCustomer:FIRST-OF(2) LABEL "First Company"
QUERY qCustomer:LAST-OF(2) LABEL "Last Company".
END.