FindTypeDefinition PowerScript function
Description
Searches for a type in one or more PowerBuilder libraries
(PBLs) and provides information
about its type definition. You can also get type definitions for system
types.
Syntax
|
1 |
<span>FindTypeDefinition</span> ( <span>typename</span> {, <span>librarylist</span> } ) |
|
Argument |
Description |
||
|---|---|---|---|
|
typename |
The name of a simple datatype, enumerated
|
||
|
librarylist |
An array of strings whose values are PowerBuilder also searches its own libraries for built-in definitions, |
Return Values
TypeDefinition. Returns an object reference with information
about the definition of typename. If any arguments
are null, FindTypeDefinition returns null.
Usage
The returned TypeDefinition object is a ClassDefinition, SimpleTypeDefinition,
or EnumerationDefinition object. You can test the Category property
to find out which one it is.
If you want to get information for a class, call FindClassDefinition instead.
The arguments are the same and you are saved the step of checking
that the returned object is a ClassDefinition object.
If you want to get information for a global function, call FindFunctionDefinition.
Examples
This example gets a TypeDefinition object for the
grGraphType enumerated datatype. It checks the category of the type
definition and, since it is an enumeration, assigns it to an EnumerationDefinition
object type and saves the name in a string:
|
1 |
TypeDefinition td_graphtype |
|
1 |
EnumerationDefinition ed_graphtype |
|
1 |
string enumname |
|
1 |
|
1 |
td_graphtype = <span>FindTypeDefinition</span>("grgraphtype") |
|
1 |
IF td_graphtype.Category = EnumeratedType! THEN |
|
1 |
ed_graphtype = td_graphtype |
|
1 |
enumname = ed_graphtype.Enumeration[1].Name |
|
1 |
END IF |
This example is a function that takes a definition
name as an argument. The argument is typename. It finds the named
TypeDefinition object, checks its category, and assigns it to the
appropriate definition object:
|
1 |
TypeDefinition td_def |
|
1 |
SimpleTypeDefinition std_def |
|
1 |
EnumerationDefinition ed_def |
|
1 |
ClassDefinition cd_def |
|
1 |
|
1 |
td_def = FindTypeDefinition(typename) |
|
1 |
CHOOSE CASE td_def.Category |
|
1 |
CASE SimpleType! |
|
1 |
std_def = td_def |
|
1 |
CASE EnumeratedType! |
|
1 |
ed_def = td_def |
|
1 |
CASE ClassOrStructureType! |
|
1 |
cd_def = td_def |
|
1 |
END CHOOSE |
This example searches the libraries in the array ls_libraries to
find the class definition for w_genapp_frame:
|
1 |
TypeDefinition td_windef |
|
1 |
string ls_libraries[ ] |
|
1 |
|
1 |
ls_libraries[1] = "c:pwrsizappwindows.pbl" |
|
1 |
ls_libraries[2] = "c:pwrsframewkwindows.pbl" |
|
1 |
ls_libraries[3] = "c:pwrsframewkancestor.pbl" |
|
1 |
|
1 |
td_windef = <span>FindTypeDefinition</span>( |
|
1 |
"w_genapp_frame", ls_libraries) |