Top
PowerCOBOL V11.0 User's Guide
FUJITSU Software

9.6.3 Returning a Value from a Child Form opened by CallForm

For modal child forms, i.e. those opened using the CallForm method, you can also pass a data value to the parent form by using the result parameter in the CloseForm method. This value is set in the RETURNING parameter of the CallForm statement.

For example, suppose you want to take different actions in the parent form depending on whether the OK or Cancel button was used to close the child form. In the Click event of the child form's OK button you would code:

  WORKING-STORAGE	SECTION.
  01  ID-OK  PIC S9(9) COMP-5 VALUE 1.
  PROCEDURE	DIVISION.
      INVOKE POW-SELF "CloseForm" USING ID-OK.

And in the Click event of the Cancel button you would code:

  WORKING-STORAGE	SECTION.
  01  ID-CANCEL  PIC S9(9) COMP-5 VALUE 0.
  PROCEDURE	DIVISION.
      INVOKE POW-SELF "CloseForm" USING ID-CANCEL.

Then, in the parent form, the code to invoke the child form (SUBDLG1) and handle the different return values would look like this:

  WORKING-STORAGE	SECTION.
  01  RETURN-VALUE  PIC S9(9) COMP-5.
  PROCEDURE	DIVISION.
      INVOKE POW-SELF "CallForm" USING "SUBDLG1" RETURNING RETURN-VALUE.
      IF RETURN-VALUE = 1 THEN
*>      Process the OK button being clicked

      ELSE
*>      Process the Cancel button being clicked

      END-IF