Table of Contents

TatClass.DefineMethod Method

Registers a new method in the class.

Syntax

Unit: atScript

function TatClass.DefineMethod(AName: string; AArgCount: Integer; AResultDataType: TatTypeKind; AResultClass: TClass; AProc: TMachineProc; AIsClassMethod: Boolean = False; ADefArgCount: Integer = 0; AParameterHints: string): TatMethod;

Parameters

<-> Parameter Type Description
AName string The name by which the method will be accessible from script.
AArgCount Integer The number of input arguments received by the method.
AResultDataType TatTypeKind The data type returns by the method, in case method is function. If the method is a procedure, this must be tkNone.
AResultClass TClass If AResultDataType is tkClass, then AResultClass must contain the class of the result value (TFont, for example). Otherwise, AResultClass must be nil.
AProc TMachineProc The method wrapper which will be called by the script when the method is to be called from script. This is the method that should actually execute real Delphi method.
AIsClassMethod Boolean Optional: Default value is False

Indicates if the method is a regular method (accessible from object instance) or a class method.
ADefArgCount Integer Optional: Default value is 0

The number of default arguments of the method. Must be equal or lower than AArgCount.
If AArgCount is 5 and ADefArgCount is 2, for example, it means that last 2 input parameters are optional, so the method can be called with 3, 4 or 5 input parameters.
AParameterHints string Optionally you can pass textual info used by scripter to provide code parameter hints. The string must be in pascal format, types and default values can be ommited. See the following examples.
'ParamName;ParamName2' 'ParamName:string;ParamName2:integer' 'ParamName1:TObject;ParamName2:integer=0;ParamName3:boolean=false' Please note that the content of this string is used only for parameter hinting, and so does not affect other important info passed in other parameters, like the number of input parameters (AArgCount) or the number of default parameters (ADefArgCount). You still need to properly provide such information correctly in other parameters, as they are being ignored in AParameterHints DefineMethod will return the newly created TatMethod object.
If a method with the name AName already exists in the class, nothing is created, and DefineMethod will return the existing TatMethod object.

See also