Like data members, a method has visibility defined so that the method can be called within a class or from outside the class. A method can have zero or more parameters. Regardless of whether a method has parameters, it can return a value.

Notice that a method begins with a method statement and ends with an end method statement.

Note: A best practice is to also use a return statement for a method, even if it returns void. Returning void means the method returns no value. This is different from an output parameter that is used to return a value in the parameter list for a method.

Here is the simplified syntax for defining a class method:

method [visibility] {<return-type> | void } <method-name> 
  ( [<parameter-use> <parameter> as <type-name> ][,…]): 
  <body of method> 
  return [return-value].
end method.

Syntax Element

Description

visibility

Public, private, or protected.

return-type

Can be a built-in or user-defined type. If void is specified, the method returns no value.

parameter-use

Can be one of input, output, or input-output.

parameter

The name for the parameter.

type-name

An ABL built-in type or a user-defined type.

body of method

The ABL code necessary to implement the functionality of the method. If the method specifies a return type, the body of the method must be written to return a value of the return type specified in the definition of the method.

return-value

If the method returns a value, the value must match the type specified for return-type.

For more information, see METHOD statement.