AMT Help Files

AMT-COBOL Form Code

Automatic generation of the form code

In AMT-COBOL for A-Series, the sharing of data values between the graphical Layout Controls and the Screen Working Storage (generally a Screen Copy) is performed automatically by matching the WSOrder properties of the Layout Controls of the form with the order of the working storage items for the form in the Screen Copy.

For example, if a layout control has the WSOrder property set to 2, the value of the second working storage item under the group item with the same name as the form will be sent to that layout control. For more information, see WSOrder property.

After the layout controls WSOrder properties have been set, the code in the procedure division of the form then only needs to have the empty ws-to-form and form-to-ws sections and copy for the form buffer as shown in the examples below. Both empty sections of code will already be in the template when creating a new Form.

 working-storage section.

 copy customer_form_map.

procedure division.

 ws-to-form section.
 init-ws-to-form.
*    this functionality is implemented in the runtime library.
 exit-ws-to-form.
 
 form-to-ws section.
 init-form-to-ws.
*    this functionality is implemented in the runtime library.
 exit-form-to-ws.
     exit.

Manipulation of the form data

To manipulate the data from the form buffer before sending it to the form to be displayed, the Form needs to contain code to perform the task of changing the data values from the form buffer.

Working Storage

The form buffer fields should be copied into the code Working Storage, often this is done with a copy as shown in the example below.

 working-storage section.

 copy customer_form_map.

WS-TO-FORM section

In the Procedure Division there should be a section named 'WS-TO-FORM'. This section can contain code to change the form buffer fields output values before it is send to the corresponding Graphical Layout Controls.

Example:

 ws-to-form section.
 ws-to-form-begin.
*    fill form fields with data from workings-storage (forminput)      
     inspect tel_nr replacing all '_' by '-'.
 ws-to-form-end.
     exit.

FORM-TO-WS section

For the values coming from the Graphical Layout Controls there should also be a section named 'FORM-TO-WS'. This section can also be used to change the data of the form buffer input fields, an example of such a section is shown below.

 form-to-ws section.
 form-to-ws-begin.
*    fill working-storage (formoutput) with data from form fields
     inspect tel_nr replacing all '-' by '_'.
 form-to-ws-end.
     exit.