Progress
Language Reference


LAST Function

Interfaces
OS
SpeedScript
All
All
Yes

Returns a TRUE value if the current iteration of a DO, FOR EACH, or REPEAT . . . BREAK block is the last iteration of that block.

SYNTAX

LAST ( break-group ) 

break-group

The name of a field or expression you named in the block header with the BREAK BY option.

EXAMPLE

The first FOR EACH block produces a list of the on hand values of the items in inventory. It also automatically generates a total of these on hand values.

The second FOR EACH block does exactly the same thing, except Progress does not generate the total. Instead, the procedure uses the ACCUMULATE statement and the LAST function. Thus, you can substitute your own labels and formats for the grand total.

r-last.p
FOR EACH item BY on-hand * price DESCENDING:
     DISPLAY item-num on-hand * price (TOTAL) LABEL "Value-oh"
         WITH USE-TEXT.
END.

FOR EACH item BREAK BY on-hand * price DESCENDING:
     FORM item.item-num value-oh AS DECIMAL
          LABEL "Value-oh" WITH COLUMN 40 USE-TEXT.
     DISPLAY item-num on-hand * price @ value-oh.
     ACCUMULATE on-hand * price (TOTAL).
     IF LAST(on-hand * price) THEN DO:
        UNDERLINE value-oh.
        DISPLAY ACCUM TOTAL on-hand * price @ value-oh.
     END.
END. 

SEE ALSO

FIRST Function, FIRST-OF Function, LAST-OF Function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095