Programming Guide : Working with Classes : How You Can Reference Objects : How You Can Set and Get Attributes
 
Share this page          
How You Can Set and Get Attributes
Setting an attribute in 4GL may change the appearance or behavior of the object. For example, setting the value of the FileHandle attribute for the BitmapObject system class actually causes OpenROAD to load a bitmap image into the object.
Sometimes setting an attribute for one object affects other objects. For example, if you set the InputFocusField attribute of the FrameExec object, OpenROAD moves the input focus from the current field to the field you specify; doing so triggers appropriate Exit and Entry events for the fields.
Use an assignment statement to assign a new value to the attribute. The basic format is:
reference_variable.attribute = expression
reference_variable
Specifies the name of the reference variable that points to the object
attribute
Specifies any one of the attributes defined for the object's system class
expression
Specifies any 4GL expression that is the appropriate type for the particular attribute
The following example changes the mode of the current frame by setting the value of the CurMode attribute to FM_READ:
CurFrame.CurMode = FM_READ;
To set the value of an attribute for a field or menu item, you must use the field function in the assignment statement. The syntax is:
field(display_variable).attribute = expression
The following example uses the field function to set the value of the CurBias attribute for the Create button:
field(create_button).CurBias = FB_INVISIBLE;
Note:  When you set the value of an attribute for a child field inside a named composite field, you must specify the full name of the field. To change the bias of the cname field in the customer subform, for example, you would use the following statement:
field(customer.cname).CurBias = FB_INVISIBLE;
There are also occasions when you want to get an attribute's value. For example, you may want to learn which field has the current input focus or which field triggered an event. The process for getting the value of an attribute is very similar to that for setting one. Use an assignment statement to obtain the value of the attribute. The basic format is:
variable = reference_variable.attribute
variable
Can be a global variable or any variable. This variable must have an appropriate data type for the particular attribute.
The following example assigns the field that currently has input focus to the reference variable charfield. Note that InputFocusField is an object.
charfield = CurFrame.InputFocusField;
To get the value of an attribute for a field or menu item, you use the field function in the assignment statement. The syntax is:
variable = field(display_variable).attribute
The Language Reference Guide online help specifies which attributes you can set (or write) and which attributes are read-only for each system class.