FindMatchingFunction

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

classdefobject.FindMatchingFunction ( scriptname, argumentlist )

Argument

Description

classdefobject

The name of the ClassDefinition object describing the class in which you want to find a function.

scriptname

A string whose value is the name of the function.

argumentlist

An unbounded array of strings whose values are the datatypes of the function arguments. If the variable is passed by reference, the string must include "ref" before the datatype. If the variable is an array, you must include array brackets after the datatype.

The format is:

{ ref } datatype { [] }

For a bounded array, the argument must include the range, as in:

ref integer[1 TO 10]

Returns

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

Example 1

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:

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

Example 2

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:

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