Example 1: Two independent record lists

Form file "simple_list.per":
LAYOUT
GRID
{
<T t1                             >
[c1  |c2                          ]
[c1  |c2                          ]
[c1  |c2                          ]
}
END
END
ATTRIBUTES
c1 = FORMONLY.col1;
c2 = FORMONLY.col2;
END
INSTRUCTIONS
SCREEN RECORD sr(FORMONLY.*);
END
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
The module "list2.4gl" (quite the same code as list1.4gl):
DEFINE arr DYNAMIC ARRAY OF RECORD
           id INTEGER,
           name VARCHAR(50)
       END RECORD

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

FUNCTION terminate_list2()
    TERMINATE DIALOG control_list2
    CLOSE WINDOW w_list2
END FUNCTION

DIALOG control_list2()
    DISPLAY ARRAY arr TO sr.*
        ON ACTION clear_row
           INITIALIZE arr[arr_curr()].* TO NULL
        ON ACTION close
           CALL terminate_list2()
    END DISPLAY
END DIALOG
Program file:
IMPORT FGL list1
IMPORT FGL list2
MAIN
  OPTIONS INPUT WRAP
  CALL start_list1()
  CALL start_list2()
  WHILE fgl_eventloop()
  END WHILE
END MAIN