4D v16.3

Searching for unused elements

Home

 
4D v16.3
Searching for unused elements

Searching for unused elements  


 

 

Two new search commands allow you to detect variables and methods that are not used in your code. You can then remove them to free up memory.
These commands are found in the Edit menu of the Design environment:

The Find Unused Methods and Global Variables command looks for project methods as well as "global" variables (process and interprocess variables) that are declared but not used. The search results appear in a standard Results window.

A project method is considered to be unused when:

  • it is not in the Trash,
  • it is not called anywhere in the 4D code,
  • it is not called by a menu command,
  • it is not called as a string constant in the 4D code (4D detects a method name in a string even when it is followed by parameters in parentheses).

A process or interprocess variable is considered to be unused when:

  • it is declared in the 4D code by a declaration command of the C_XXX or ARRAY XXX type,
  • it is not used anywhere else in the 4D code,
  • it is not used in any form object.

Note that certain uses cannot be detected by the function - i.e. an element considered unused may in fact be used. This is the case in the following code:

 v:="method"
 EXECUTE FORMULA("my"+v+String(42))

This code builds a method name. The mymethod42 project method is considered unused when in fact it is called.
Therefore, it is advisable to check that the elements declared as unused are in fact unnecessary before you remove them.

The Find Unused Local Variables command looks for local variables that are declared but not used. The search results appear in a standard Results window.

A local variable is considered to be unused when:

  • it is declared in the 4D code by a command of the C_XXX or ARRAY XXX type,
  • it is not used anywhere else within the same method.

 
PROPERTIES 

Product: 4D
Theme: Searching and replacing in the Design

 
HISTORY 

 
ARTICLE USAGE

4D Design Reference ( 4D v16)
4D Design Reference ( 4D v16.1)
4D Design Reference ( 4D v16.3)