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.
Applies to
ClassDefinition objects
Syntax
|
1 |
classdefobject.FindMatchingFunction ( scriptname, argumentlist ) |
|
Argument |
Description |
||||
|---|---|---|---|---|---|
|
classdefobject |
The name of the ClassDefinition object describing the |
||||
|
scriptname |
A string whose value is the name of the function. |
||||
|
argumentlist |
An unbounded array of strings whose values are the The format is:
For a bounded array, the argument must include the range,
|
Return value
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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
string ls_args[] ScriptDefinition sd ls_args[1] = "ref dragobject" ls_args[2] = "double" ls_args[3] = "integer" ls_args[4] = "integer" sd = c_obj.FindMatchingFunction( & "OpenUserObjectWithParm", ls_args) IF NOT IsValid(sd) THEN mle_1.Text = "No matching script" ELSE mle_1.Text = uf_scriptinfo(sd) 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 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
string s, lineend integer li lineend = "~r~n" // Script name s = s + scriptobj.Name + lineend // datatype of the return value s = s + scriptobj.ReturnType.DataTypeOf + lineend // List argument names s = s + "Arguments:" + lineend FOR li = 1 to UpperBound(scriptobj.ArgumentList) s = s + scriptobj.ArgumentList[li].Name + lineend NEXT // List local variables s = s + "Local variables:" + lineend FOR li = 1 to UpperBound(scriptobj.LocalVariableList) s = s + scriptobj.LocalVariableList[li].Name & + lineend NEXT RETURN s |
See also