Extracting a function

You can use the Extract Function to clean up your lengthy or overly-complicated functions.

About this task

When you extract a function, note that the Extract Function is disabled if the code fragment that you select is in an interface, record, external type, form, or form group parts that cannot contain function declaration.

To extract a function, complete the following steps:

Procedure

  1. In the EGL editor, select a set of statements from a nested function or a top-level function and then right-click.
  2. From the pop-up menu, click Refactor > Extract Function. The Extract EGL Function window is displayed. If an error message is displayed, stating that your code selection is not complete, click Expand Selection To to extend your selection to a valid fragment. See Expanding your selection for information about how to expand your code selection.
  3. In the Function name field, enter a function name that complies with naming conventions of EGL and is unique in the current scope. The function parameters are listed in the table and they cannot be changed.
  4. To preview the changes, click Preview. The preview page displays the changes that will be made. Click OK to extract the function.

Results

A new function that contains the statements you selected is created. Your selection is replaced with a reference to the new function.

Feedback