<< Click to Display Table of Contents >> Navigation: »No topics above this level« Directive "Include" |
mapp Services V5.16
The "Include" directive loads a file and parses it as part of the current source code.
#include 'filename'
The "Include" directive opens the specified file and adds the text of the file in place of the directive. The contents of the included file becomes part of the source file where the directive appears.
The "Include" directive can be written anywhere in a program with a few exceptions. The "Include" directive cannot be specified in the following places:
•The middle of an IEC ST statement or declaration
•Within an ACTION definition
Syntax errors in included files are reported in the included files. Nevertheless, runtime errors in an included file are reported as occurring in the including files, but with the line number from the included file.
#include 'defs.typ' // Include type definitions.
VAR {AT PLC}
Context : AppContextType; // AppContextType defined in defs.typ
END_VAR
// Declare PLC task content
#pragma TASK_NAME 'ITask' // Load declarations of PLC task ITask
#pragma SCOPE PLC_GLOBAL // Ensure ITask variables area picked up
#include 'ITask.typ' // Types are shared among programs of all axis groups
#include 'ITask.var' // Variables of PLC task Itask shared among programs of all axis groups
#pragma SCOPE DEFAULT
#pragma TASK_NAME
// Interpreted main program
PROGRAM _MAIN
// Statements
END_PROGRAM