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 objectsom
- 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.
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
orOPEN 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 theWindow
class. class methods are called using the class identifier (ui.Window
). You can specify theWindow
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
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
01
MAIN
02
DEFINE
mywin ui.Window
03
04
OPEN WINDOW
w1 WITH FORM
"testform"
05
LET
mywin = ui.Window.getCurrent()
06
CALL
mywin.setText("test")
07
MENU
08
ON ACTION
quit
09
EXIT MENU
10
END MENU
11
12
END MAIN