Example 2: Simple list

The module "list1.4gl":
DEFINE arr DYNAMIC ARRAY OF RECORD
           id INTEGER,
           name VARCHAR(50)
       END RECORD

FUNCTION start_list1()
    DEFINE i INTEGER
    IF ui.Window.forName("w_list1") IS NULL THEN
       FOR i=1 TO 10
           LET arr[i].id = i
           LET arr[i].name = "Record "||i
       END FOR
       OPEN WINDOW w_list1 WITH FORM "simple_list"
       START DIALOG control_list1
    ELSE
       CURRENT WINDOW IS w_list1
    END IF
END FUNCTION

FUNCTION terminate_list1()
    TERMINATE DIALOG control_list1
    CLOSE WINDOW w_list1
END FUNCTION

DIALOG control_list1()
    DISPLAY ARRAY arr TO sr.*
        ON ACTION add_row
           CALL DIALOG.appendRow("sr")
           LET arr[arr.getLength()].id = arr.getLength()
           LET arr[arr.getLength()].name = "[new record]"
        ON ACTION close
           CALL terminate_list1()
    END DISPLAY
END DIALOG

For the complete example, see Example 1: Two independent record lists.