Form example: dispcust.per

This form specification file is used with the dispcust.4gl program to display program variables to the user. This form uses a layout with a simple GRID to define the display area.

File dispcust.per:
  1 SCHEMA custdemo
  2 
  3 LAYOUT
  4 GRID
  5 {
  6 Customer:[f1   ] Name:[f2                  ]
  7  Address:[f3                                    ]
  8     City:[f4              ]State:[f5]Zip:[f6    ]
  9  Contact:[f7                            ]
 10    Phone:[f8                 ]          
 11 }
 12 END
 13 END
 14 
 15 TABLES
 16 customer
 17 END
 18 
 19 ATTRIBUTES
 20 EDIT f1=customer.cust_num, NOENTRY;
 21 EDIT f2=customer.cust_name, REQUIRED, NOT NULL, COMMENT="Customer name";
 22 EDIT f3=customer.addr;
 23 EDIT f4=customer.city;
 24 EDIT f5=customer.state;
 25 EDIT f6=customer.zipcode;
 26 EDIT f7=customer.contact_name;
 27 EDIT f8=customer.phone;
 28 END
Note:
  • Line 1 defines the database schema file from which the form field data types will be obtained.
  • Lines 3 through 13 delimit the LAYOUT section of the form where item tags are used.
  • Lines 4 thru 11 delimit the GRID area, indicating what will be displayed to the user between the curly brackets.
  • Line 15: The TABLES statement is required since the field descriptions reference the columns of the database table customer.
  • Within the grid area, the form fields have item tags linking them to descriptions in the ATTRIBUTES section. As an example, f1 is the display area for a program variable having the same data type definition as the cust_num column in the customer table of the custdemo database.
  • Line 20: All of the item-tags in the form layout section are listed in the ATTRIBUTES section. For example, the item-tag f2 is listed as having an item-type of EDIT. This field will be used for display only in this program, but the same form will be used for input in a later program. An additional attribute, REQUIRED, indicates that when this form is used for input, an entry in the field cust_name must be made. NOT NULL prevents the user from trying to set an empty cust_name , which would result in an error message from the database.
  • Line 21: The second field is defined with the attribute COMMENT, which specifies text to be displayed when this field gets the focus, or as a tooltip when the mouse goes over the field.