ClassName

Determines the class of an object or the datatype of a variable.

To determine

Use

The class of an object

Syntax 1 For any object

The class (or datatype) of a variable

Syntax 2 For variables


Syntax 1 For any object

Description

Provides the class (or name) of the specified object.

Applies to

Any control

Syntax

controlname.Classname ( )

Argument

Description

controlname

The name of the control for which you want to know the name assigned to the control in the style window (the class of the control)

Returns

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 PocketBuilder 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

Example 1

These statements return the class of the dragged control Source:

DragObject Source

string which_class


Source = DraggedObject()

which_class = Source.ClassName()

Example 2

These statements return the class of the objects in the control array and store them in the_class array:

string the_class[]

windowobject the_object[]

integer i


FOR i = 1 TO UpperBound(control[])

    the_object[i] = control[i]

    the_class[i] = the_object[i].ClassName()

NEXT

See also


Syntax 2 For variables

Description

Provides the datatype of a variable.

Syntax

ClassName ( variable )

Argument

Description

variable

The name of the variable for which you want to know its name (that is, its datatype)

Returns

String. Returns the name of variable. Returns the empty string ("") if variable is an enumerated datatype or if an error occurs. If variable is null, ClassName returns null.

Usage

ClassName cannot determine the datatype if variable is an enumerated datatype. In this case, ClassName returns the empty string.

Examples

Example 3

If gd_double is a global double variable, ClassName sets varname to double:

string varname

varname = ClassName(gd_double)