Creating a Method - Example

From Appmethod Topics
Jump to: navigation, search

Go Up to Object Pascal Class Explorer Topics

Assume that you want to insert a privately declared function named Test into a class named TTestClass.

The new function shall have two arguments i and j, both of the integer type and it should return a boolean value.

To add such a function you should specify the following options in the Add Method dialog box:

  1. Type Test in Method name.
  2. Select the TTestClass class name in the Add to class combo box.
  3. Type I : Integer; J : Integer in the Arguments field.
  4. Check the function option in the Method type group, then select Boolean in the Return type combo box.
  5. Check the private option in the Visibility group.
  6. Click OK. The Object Pascal Class Explorer adds the following code for the function with the specified options:
    • Into the declaration of the TTestClass class: TTestClass = class .... private function Test(I : Integer; J : Integer): boolean; .... end; .
    • Into the implementation section of the unit file.

See Also