The Methods menu of the Class Browser or Primitive Types Browser enables you to audit the local variables in the current method, display those that are unused, and remove one unused local variable or all unused local variables in the method.
To audit and maintain local variables in the method displayed in the editor pane
Select the Unused Local Variables command from the Methods menu. (This command is disabled if the method is uncompiled or in error.)
If there are no unused variables, a message box displays There are no unused local variables.
If there is one or more unused local variable in the method, the first unused local variable is highlighted in the editor pane and the Find Unused Variables dialog displays the name of the first unused local variable.
To display the next unused variable, click the Find Next button. If there are no more in the current method, the dialog is closed and a message box displays There are no more unused local variables.
To remove the displayed unused variable from the method source, click the Remove button.
The logic then continues as though you had clicked the Find Next button.
To remove all unused variables from the method source, click the Remove All button.
The dialog is then closed and a message box lists the names of all variables that have been removed from the method.
To close the Find Unused Variables dialog, click the Cancel button. (No previous remove actions are undone.)
Any changes made to the method can be undone and the method will be unsaved. (Pressing F8 saves and recompiles a changed method.)
The Schema menu in the Schema Browser enables you to audit the local variables that are unused in all methods in a schema or class.
To audit local variables and parameters in all methods or a class of the schema selected in the Schema Browser
Select the Find Unused Local Variables/Parameters command from the Schema menu.
The Find Unused Local Variables and Parameters dialog, shown in the following image, is then displayed.
If you do not want to search for unused local variables and parameters in all methods in all schemas (the default value), perform one of the following actions in the Search Criteria group box.
Select the Search selected schema option button and in the combo box below the option button, select the schema in which you want to locate unused local variables and parameters in all methods.
Select the Search selected schema and all sub-schemas option button and in the combo box above the option button, select the schema in which you want to locate unused local variables and parameters in all methods in that schema and its subschemas.
Select the Search selected class in selected schema option button and in the combo box below the option button, select the class of the schema selected in the first combo box or that has a local copy class whose methods will be scanned for unused local variables and parameters.
In the Reporting Options group box, uncheck the:
Local Variables check box if you do not want to display unused local variables. This check box is checked by default; that is, unused local variables are output to the report.
Method Parameters check box if you do not want to display unused method parameters. This check box is checked by default; that is, unused method parameters are output to the report.
If you want to display unused method parameters in all methods in the schema instead of all methods except for event methods (the default), select the All Methods option button. The Parameters group box is visible only when the Method Parameters check box is checked.
In the Output Options group box, select the Print Preview option button if you want to preview the unused local variables and parameters report output.
By default, the Methods List Browser option button is selected, indicating that the unused local variables and parameters are displayed in a Methods Browser, shown in the following image.
To display the method source with the unused item visible in the editor pane below the list on the form, click on a method in the list. You can edit this method source.
Click the Search button to initiate the search. Alternatively, click the Cancel button to abandon your selections.
When a scan is performed using the Find Unused Local Variables/Parameters command from the Schema menu and the located unused variables and parameters are displayed in the Unused Local Variables/Parameters form, double‑clicking a method entry in the list for an unused local variable entry results in all listed unused local variables being removed from the method source and the method is then recompiled. All of the unused local variable entries in the list for that method are removed from the list except for the last entry, so that you can view the method changes. You can also undo the changes, if required. (Multiple undo actions may be required.)
If there is no remaining text between the vars and begin statements, the vars section is removed. No comments are removed.
You can also remove unused local variables by selecting the Remove Unused Local Variables command in the Methods menu.
If you click the only remaining entry for a method again and there are no changes required, the entry is removed from the list.
The result of print preview search output to a print‑ready report contains the:
Schema of the method
Class in which the method is defined
Method name where the create was performed
Line number in the method of the unused variable statement or parameter
Variable name of the unused local variable or parameter
Type of value; that is, variable or parameter