TypeOf PowerScript function
Description
Determines the type of an object or control, reported as a
value of the Object enumerated datatype.
Controls
Any object
Syntax
1 |
<span>objectname</span>.<span>TypeOf</span> ( ) |
Argument |
Description |
---|---|
objectname |
The name of the object or control for |
Return Values
Object enumerated datatype. Returns the type of objectname.
If objectname is null, TypeOf returns null.
Usage
Use TypeOf to determine the type of a selected
or dragged control.
Examples
If dw_Customer is a
DataWindow control, this statement returns DataWindow!:
1 |
dw_Customer.<span>Typeof</span>() |
This example looks at the first five controls in
the w_dept window’s Control array
property. The loop executes some statements for each control that
is a CheckBox:
1 |
integer n |
1 |
FOR n = 1 to 5 |
1 |
IF w_dept.Control[n].<span>TypeOf</span>() = CheckBox! THEN |
1 |
... // Some processing |
1 |
END IF |
1 |
NEXT |
This loop stores in the winobject array the type
of each object in the window’s Control array property:
1 |
object winobjecttype[] |
1 |
long ll_count |
1 |
FOR ll_count = 1 to UpperBound(Control[]) |
1 |
winobjecttype[ll_count] = & |
1 |
<span> TypeOf</span>(Control[ll_count]) |
1 |
NEXT |
If you do not know the type of a control passed via
PowerObjectParm in the Message object, the following example assigns
the passed object to a graphic object variable, the ancestor of
all the control types, and assigns the type to a variable of type
object, which is the enumerated datatype that TypeOf returns. The CHOOSE
CASE statement can include processing for each control
type that you want to handle. This code would be in the Open event
for a window that was opened with OpenWithParm:
1 |
graphicobject stp_obj |
1 |
object type_obj |
1 |
1 |
stp_obj = Message.PowerObjectParm |
1 |
type_obj = stp_obj.<span>TypeOf</span>() |
1 |
1 |
CHOOSE CASE type_obj |
1 |
CASE DataWindow! |
1 |
MessageBox("The object"," Is a datawindow") |
1 |
1 |
CASE SingleLineEdit! |
1 |
MessageBox("The object"," Is a sle") |
1 |
1 |
... // Cases for additional object types |
1 |
CASE ELSE |
1 |
MessageBox("The object"," Is irrelevant!") |
1 |
END CHOOSE |