Built-in Classes

Included in the predefined functions that are built into Genero are special groups (classes) of functions (methods) that act upon the objects that are created when your program is running. Each class of methods interacts with a specific program object, allowing you to change the appearance or behavior of the objects. Because these methods act upon program objects, the syntax is somewhat different from that of functions.

The classes are gathered together into packages:

  • ui - classes related to the objects in the graphical user interface (GUI)
  • base - classes related to non-GUI program objects
  • om - classes that provide DOM and SAX document handling utilities

This tutorial focuses on using the classes and methods in the ui package to modify the user interface at runtime.

Note: Variable names, class identifiers, and method names are not case-sensitive; the capitalization used in the examples is for ease in reading.

Using the Classes

This example for the Window class also presents the general process that you should use.

The methods in the Window class interact with the Window objects in your program.

Getting a reference to the object

Before you can call any of the methods associated with Window objects, you must identify the specific Window object that you wish to affect, and obtain a reference to it:

  • Define a variable to hold the reference to the Window object. The data type of the variable is the class identifier (ui.Window):
     DEFINE mywin ui.Window
  • Open a window in your program using the OPEN WINDOW or OPEN WINDOW ... WITH FORM instruction:
     OPEN WINDOW w1 WITH FORM "testform"
  • Get a reference to the specific Window object by using one of two class methods provided by the Window class. class methods are called using the class identifier (ui.Window). You can specify the Window object by name from among the open windows in your program, or choose the current window.
    LET mywin = ui.Window.getCurrent() -- returns a reference to 
                                       -- the current window object
    LET mywin = ui.Window.forName("w1")-- returns a reference to 
                                       -- the open window named "w1"

Calling a method

Now that you have a reference to the object, you can use that reference to call any of the methods listed as object methods in the Window class documentation. For example, to change the window title for the window referenced by mywin:
CALL mywin.setText("test")

See The Window class in the Genero Business Development Language User Guide for a complete list of the methods in this class.

Example 1

02 DEFINE mywin ui.Window 
04 OPEN WINDOW w1 WITH FORM "testform"
05 LET mywin = ui.Window.getCurrent()
06 CALL mywin.setText("test")
08  ON ACTION quit 
Figure: Form with window title changed by the ui.Window.setText method

This figure is a screenshot of a window with the title set to "test" by the ui.Window.setText method.