Global Variables

Hello everybody, I have the following questions about the editor. Similar to CodeSys or TwinCAT, I want to create global variables, which can be reached and used by every program and function block. I would also like to call a program from another program. Is this possible?

Hello, You can create Global variables in PLCnext Engineer in the “PLC” branch of the project tree: 24 10 2019 08 06 40 It’s recommended to define your global variables in the “Default” group, or in another user-created group, rather than in the “System Variables” group. Now, in any POU (program, FB or function), you can define a variable with the same name as the Global variable, and mark the “Usage” of that variable as “External”. The POU variable now refers to the global variable you defined in the PLC section. =================================== Regarding your requirement to call a program from another program - you can:

                                               * call Functions from others functions, and from FBs, and from Programs.
                                               * call FBs from other FBs, and from Programs.
                                               * trigger the start of a Task containing a Program, from another Program.

Will any of these options do what you need? Martin.

Thank you. I’ll take care of it,

that helped me a lot. I have one more question. I want to create and use a FB like a variable Global.
If I want to use this instance on the global variables, I am told that the function module instance is not known. Is it possible to define FBs globally? Edit: Okay, i get it. :slight_smile:

FB’s are general available for all programs. You just have to call / drag them in to your program. If you don’t like the generated name, you can re-name the FB to your liking in the variable sheet, but remember to re-name the FB also in the code sheet. I tend to first declare my FB’s in the variable sheet and call them afterwards in the code sheet. Peter Paul