Finding Declarations

TwinCAT offers the option of searching the entire project for the definition location of a variable or function. The function block containing the definition opens in the editor, and the declaration is selected.

Finding the declaration of a variable

A POU is open in the editor.
1. Place the cursor on an identifier in the implementation.
2. In the context menu of the editor select the command Go To Definition.
The POU containing the definition opens in the editor, and the variable definition is selected. If the definition is located in a “compiled” library, the corresponding function block opens in the library manager.
Finding Declarations 1:

You can use the command in offline and online mode.

Examples:

The following function block contains a function block definition (fbInst), a program call (SampleProg()) and a function block call (fbInst.nOut):

VAR
    fbInst : FB_Sample;
    nVar : INT;
    nRes : INT;
END_VAR

SampleProg();
nVar := SampleProg.nVar1;
nRes := fbInst.nOut;

If you place the cursor on SampleProg, the command opens the SampleProg program in its editor.

If you place your cursor on fbInst, the command puts the focus on the declaration window in line fbInst : FBSample;

If you place your cursor on nOut, the command opens the function block FB_Sample in its editor.

See also: