The .4gl File - Interacting with the User
Your form can display options to the user using action views - buttons, dropdown menus (topmenus), toolbars, and other items on the window.
Displaying Messages and Errors
The MESSAGE and ERROR statements are used to display text
containing a message to the user. The text is displayed in a specific area, depending on the
front end configuration and window style. The MESSAGE text is displayed
until it is replaced by another MESSAGE statement or field comment. You can
specify any combination of variables and strings for the text. BDL generates the message to
display by replacing any variables with their values and concatenating the strings:
MESSAGE "Customer " || l_custrec.store_num , || " retrieved."
The Localized Strings feature can be used to customize the messages for specific user communities. This is discussed in Tutorial Chapter 10: Localization.
Example: dispcust.4gl
This portion of the dispcust.4gl program connects to a database, opens a window and displays a form and a menu.
01 -- dispcust.4gl
02 SCHEMA custdemo
03
04 MAIN
05
06 CONNECT TO "custdemo"
07
08 CLOSE WINDOW SCREEN
09 OPEN WINDOW custwin WITH FORM "custform"
10 MESSAGE "Program retrieves customer 101"
11
12 MENU "Customer"
13 ON ACTION query
14 CALL query_cust()
15 ON ACTION exit
16 EXIT MENU
17 END MENU
18
19 CLOSE WINDOW custwin
20
21 DISCONNECT CURRENT
22
23 END MAIN- Line
02TheSCHEMAstatement is required since variables are defined asLIKEa database table in the functionquery_cust. - Line
06opens the connection to thecustdemodatabase. - Line
08closes the default window namedSCREEN, which is opened each time the runtime system starts a program containing interactive statements - Line
09uses theWITH FORMsyntax to open a window having the identifiercustwincontaining the form identified ascustform. The window name must be unique among all windows defined in the program. Its scope is the entire program. You can use the window's name to reference any open window in other modules with other statements. Although there can be multiple open windows, only one window may be current at a given time. By default, the window that opens will be a normal application window. The form identifier is the name of the compiled .42f file (custform.42f). The form identifier must be unique among form names in the program. Its scope of reference is the entire program. - Line
10displays a string as aMESSAGEto the user. The message will be displayed until it is replaced by a different string. - Lines
12through17contain the interactiveMENUstatement. By default, the menu options query and exit are displayed as buttons in the window, withCustomeras the menu title. When theMENUstatement is executed, the buttons are enabled, and control is turned over to the user. If the user selects the query button, the functionquery_custwill be executed. Following execution of the function, the action views (buttons in this case) are re-enabled and the program waits for the user to select an action again. If the user selects the exit button, theMENUstatement is terminated, and the program continues with line 19. - Line
19The windowcustwinis closed which automatically closes the form, removing both objects from the application's memory. - Line
21The program disconnects from the database; as there are no more statements inMAIN, the program terminates.