OPEN FORM

 

OPEN FORM statement declares a form-name of a compiled 4GL screen form so that it could be referenced by the DISPLAY FORM statement.

 

 

Element

Description

Form Name

The name you want to assign to the opened form

Form File

A 4GL expression that returns the name of the form file and its relative path, if required

 

To display a screen form, follow these steps:

  1. Create a screen form (in the .per format or in the .4fm format) and compile it.

  2. Declare the name of the form by means of the OPEN FORM statement

  3. Display the declared form with the help of the DISPLAY FORM statement

 

The displayed form can be activated by means of the CONSTRUCT, DISPLAY ARRAY, INPUT, or INPUT ARRAY statement. When the OPEN FORM statement is executed, the form file is loaded into memory.

 

 

Form Name

 

Form name that follows the OPEN FORM keywords can be represented by a character string, it need not to be declared previously. The form-name does not need to match the name of the form file. However, it should be unique among the other forms used by the program. The form-name can be referenced in any part of the program once it has been declared by means of the OPEN FORM statement.

 

The file-name of the form must follow the FROM keywords. It must specify the name of the file without the extension, but with the relative path, if it is required. The file-name should be enclosed into the quotation marks. The path is required for form files located not in the same folder as the file which contains the corresponding OPEN FORM statement.

 

OPEN FORM my_form FROM "/forms/form_file1"

 

 

Form File

 

Form files can be specified in the following ways:

 

The name of the form file must not include the file extension. Below is an example of a 4GL expression used after the FROM keyword:

 

DEFINE

      f_file STRING,

      id_number SMALLINT

LET id_number = 12

LET f_file = "file00"||id_number

OPEN FORM my_f FROM f_file

 

The form file opened in the example above must be called file0012.

 

 

Displaying forms to a 4GL Window

 

There are two ways of displaying a screen form in a 4GL window:

 

MAIN

OPEN WINDOW window1 AT 2,2 WITH 15 ROWS, 50 COLUMNS

ATTRIBUTE (BORDER)

OPEN FORM my_form FROM "forms/form_file1"

DISPLAY FORM my_form

END MAIN

 

If the size of the form displayed by the DISPLAY FORM statement is larger than the window in which it is displayed, a runtime error -1142 will occur, informing you that the window is too small to display the form

 

 

 

OPEN WINDOW window2 AT 2, 2 WITH FORM "form_file1"

 

When a form is displayed by means of the OPEN WINDOW … WITH FORM statement, the window will be the same size as the form, so you cannot receive error -1142.

 

If you use the same form-name in another OPEN FORM statement, the previously opened form will be closed and 4GL will open a new one.

 

If you open a screen form in a 4GL window, you do not need to use the statement CLOSE FORM to release the memory allocated to the form. The form will be closed and the memory will be released when the corresponding 4GL window is closed by means of the CLOSE WINDOW statement.