Syntax 1 For any object
Description
Provides the class (or name) of the specified object.
Controls
Any control
Syntax
|
1 |
<span>controlname</span>.<span>Classname</span> ( ) |
|
Argument |
Description |
|---|---|
|
controlname |
The name of the control for which you |
Return Values
String. Returns the class of controlname,
the name assigned to the control. Returns the empty string (“”)
if an error occurs. If controlname is null, ClassName returns null.
Usage
The class is the name of an object. You assign the name when
you save the object in its painter. Usually the class and the object
itself appear to be the same (because PowerBuilder declares a variable
with the same name as the class for the object). However, if you
have declared multiple instances of an object, it is clear that
the object’s class and the object’s variable are
different.
If an ancestor object has been instantiated with one of its
descendants, you can use ClassName to find the name of the descendant.
TypeOf reports an object’s built-in object type.
The types are values of the Object enumerated datatype, such as Window!
or CheckBox!. ClassName reports
the class of the object in the ancestor-descendant hierarchy.
Examples
These statements return the class of the dragged
control Source:
|
1 |
DragObject Source |
|
1 |
string which_class |
|
1 |
|
1 |
Source = DraggedObject() |
|
1 |
which_class = Source.<span>ClassName</span>() |
These statements return the class of the objects
in the control array and store them in the_class array:
|
1 |
string the_class[] |
|
1 |
windowobject the_object[] |
|
1 |
integer i |
|
1 |
|
1 |
FOR i = 1 TO UpperBound(control[]) |
|
1 |
the_object[i] = control[i] |
|
1 |
the_class[i] = the_object[i].<span>ClassName</span>() |
|
1 |
NEXT |
Suppose your object hierarchy has a window named ancestor_window and
it has descendants called win1 and win2,
and the user can choose which descendant to open as a sheet. The
following code tests which descendent window class is currently
active (the MDI frame is w_frame):
|
1 |
ancestor_window active_window |
|
1 |
active_window = w_frame.GetActiveSheet() |
|
1 |
IF <span>ClassName</span>(active_window) = "win1" THEN |
|
1 |
. . . |
|
1 |
END IF |