Avoid validation errors when updating programs and routines in the Code Editor
When updating programs and routines in the Code Editor, validation errors occur because
of missing or duplicate implementations or forward declares.
In
FactoryTalk® Design Studio™
, an implementation is the actual definition of the program or routine, including its
properties, tags, and content. Example of an implementation

A forward declaration signifies that an element exists, but its implementation resides in
a different location, most often in another file. For example, a forward declaration of
a routine informs the parent program that it contains a routine, but the routine
implementation is in another file. Forward declarations are indicated by placing the
keyword
extern
in front of the declaration's signature. The
signature includes the name and sets of parameters (order, names, types, and usage).
This approach helps in organizing code into separate files, keeping them small, and
allowing implementations to be more easily managed when performing Version Control
System merges and potential merge conflicts.Example of a forward declare

Examples of a forward declare and program and routine implementations

To avoid introducing validation errors into the code, follow these guidelines:
- Editing the name of a program or routine:
- When editing the name of a program or routine, change both the forward declare and the implementation.
- Edit the name in thePropertiespanel instead of using the Code Editor. If you edit the name in thePropertiespanel, the system will update the name in both the forward declare and the implementation.
- To edit the name in the Code Editor, right-click the component and selectOpen Code Editorto change the name in the implementation. Then right-click the parent container and selectOpen Code Editorto change the name on the line with the external declare.TIP: Changing the name of an element in the Code Editor only updates the text, not all references. Use the Properties panel to ensure both forward declares and implementations are updated.
- Deleting a program or routine:
- When deleting a program or routine, delete both the forward declare and the implementation.
- Instead of using the Code Editor, if you delete the program or routine by right-clicking the component in the Explorer and selectingDelete, the system deletes both the forward declare and the implementation.
- To delete the program or routine in the Code Editor, right-click the component and selectOpen Code Editorto delete the implementation. Then right-click the parent container and selectOpen Code Editorto delete the external declare.TIP: Deleting through the explorer panel ensures all associated files and directories are removed. Avoid deleting by text in the Code Editor, as it does not clean up implementation files
- Creating a program or routine:
- When creating a program or routine, create both the forward declare and the implementation.
- Instead of using the Code Editor, if you create the program or routine by right-clicking the parent component in the Explorer and selectNew programorNew routine, the system creates both the forward declare and the implementation.
- If you create the component as an inline component instead of using theexternkeyword, see Inline and external routines for guidance.
- When creating these components in the Code Editor, verify that the name is unique.
- If validation errors occur, double-click the error inOutputto navigate to the error inFactoryTalk Design Studio.
Provide Feedback