FindMatchingFunction PowerScript function
Description
Finds out what function in a class matches a specified signature.
The signature is a combination of a script name and an argument
list.
Controls
ClassDefinition objects
Syntax
|
1 |
<span>classdefobject.</span><span>FindMatchingFunction</span> ( <span>scriptname</span>, <span>argumentlist</span> ) |
|
Argument |
Description |
||||
|---|---|---|---|---|---|
|
classdefobject |
The name of the ClassDefinition object |
||||
|
scriptname |
A string whose value is the name of the |
||||
|
argumentlist |
An unbounded array of strings whose values The format is:
For a bounded array, the argument must include the range, as
|
Return Values
ScriptDefinition. Returns an object instance with information
about the matching function. If no matching function is found, FindMatchingFunction returns null.
If any argument is null, it also returns null.
Usage
In searching for the function, PowerBuilder examines the collapsed
inheritance hierarchy. The found function may be defined in the
current object or in any of its ancestors.
Arguments passed by reference
To find a function with an argument that is passed by reference,
you must specify the REF keyword. If you have
a VariableDefinition object for a function argument, check the CallingConvention
argument to determine if the argument is passed by reference.
In documentation for PowerBuilder functions, arguments passed
by reference are described as a variable, rather than simply a value.
The PowerBuilder Browser does not report which arguments are passed
by reference.
Examples
This example gets the ScriptDefinition object that
matches the PowerBuilder window object function OpenUserObjectWithParm and
looks for the version with four arguments. If it finds a match,
the example calls the function uf_scriptinfo,
which creates a report about the script:
|
1 |
string ls_args[] |
|
1 |
ScriptDefinition sd |
|
1 |
|
1 |
ls_args[1] = "ref dragobject" |
|
1 |
ls_args[2] = "double" |
|
1 |
ls_args[3] = "integer" |
|
1 |
ls_args[4] = "integer" |
|
1 |
|
1 |
sd = c_obj.<span>FindMatchingFunction</span>( & |
|
1 |
"OpenUserObjectWithParm", ls_args) |
|
1 |
IF NOT IsValid(sd) THEN |
|
1 |
mle_1.Text = "No matching script" |
|
1 |
ELSE |
|
1 |
mle_1.Text = uf_scriptinfo(sd) |
|
1 |
END IF |
The uf_scriptinfo function
gets information about the function that matched the signature and
builds a string. Scriptobj is the ScriptDefinition object passed
to the function:
|
1 |
string s, lineend |
|
1 |
integer li |
|
1 |
lineend = "~r~n" |
|
1 |
|
1 |
// Script name |
|
1 |
s = s + scriptobj.Name + lineend |
|
1 |
// datatype of the return value |
|
1 |
s = s + scriptobj.ReturnType.DataTypeOf + lineend |
|
1 |
|
1 |
// List argument names |
|
1 |
s = s + "Arguments:" + lineend |
|
1 |
FOR li = 1 to UpperBound(scriptobj.ArgumentList) |
|
1 |
s = s + scriptobj.ArgumentList[li].Name + lineend |
|
1 |
NEXT |
|
1 |
|
1 |
// List local variables |
|
1 |
s = s + "Local variables:" + lineend |
|
1 |
FOR li = 1 to UpperBound(scriptobj.LocalVariableList) |
|
1 |
s = s + scriptobj.LocalVariableList[li].Name & <br> + lineend |
|
1 |
NEXT |
|
1 |
RETURN s |