Top
PowerCOBOL V11.0 User's Guide
FUJITSU Software

9.6.4 Identifying which Form has been Closed

When using OpenForm to invoke child forms you can have several child forms open at one time. When a child form is closed you may want to take a specific action in the parent form using the CloseChild event, so you need to know which form has been closed. You do this by passing each child an ID (called a "cookie") when you use the OpenForm (or CallForm) methods. The ID of the closed form is passed as a parameter to the CloseChild event.

For example, suppose you are going to invoke two child forms "SUBFORM1", contained in the same DLL as the parent form, and "SUBFORM2" contained in a different DLL. You would first define ID's for the child forms in the parent form:

  01  SUBFORM1-ID  PIC S9(9) COMP-5 VALUE 1 IS GLOBAL.
  01  SUBFORM2-ID  PIC S9(9) COMP-5 VALUE 2 IS GLOBAL.

You then use these ID's when you open the subforms:

      INVOKE POW-SELF "OpenForm" USING "SUBFORM1" SUBFORM1-ID.
      INVOKE POW-SELF "OpenForm" USING "SUBFORM2" "SUB.DLL" SUBFORM2-ID.

In the CloseChild event of the parent form you can then code (POW-COOKIE is defined for you automatically by PowerCOBOL):

  LINKAGE	SECTION.
  01  POW-COOKIE  PIC S9(9) COMP-5.
  PROCEDURE DIVISION USING POW-COOKIE.
      EVALUATE  POW-COOKIE
      WHEN SUBFORM1-ID
*>      Process SUBFORM1 being closed

      WHEN SUBFORM1-ID
*>      Process SUBFORM2 being closed

      END-EVALUATE