How to remove the Error 13: Variables: Contains too many variables
Can anybody tell me, how to troubleshoot the Error 13: Variables: Contains too many variables .
This error is appearing when compiling in the Application Global variable. around 2000 variables are declared in the list with different structure data types.
Version of 800xA is 5.0.2
Voted best answer
Something to think about ...
A "RealIO" datatype contains 5 properties. One of those properties is a structured datatype with another 5 sub properties. So every "RealIO" datatype in your application actualy has TEN variables. So your 2000 I/O points rapidly become 20,000 variables.
So while 65,000 variables might sound like a lot - it is NOT.
Your real problem is that you are declaring everything as a "global" variable. If you did this in a VB or C program ( ie declared everything as "public"), then pretty much every textbook will tell you that this is really really bad practice, and can lead to all sorts of problems with incorrect connections, unexpected bugs from programming mistakes and problems re-using your code. ( and the same arguments also apply to "External Variables" )
As MyMe alreay said - you need to break up your code into appropriately sized applications and make most of your variable declarations local to the POU where they are used. If you are using Control Modules then you are forced into using more global variables, but the global variables are mainly required to communicate between the modules, and most of your "variables" should end up being either control module parameters or local variables inside the control modules. If you are not using control modules, then you can make pretty much everything local to the Programs (incuding IO connections) and almost eliminate global variables entirely.
The answer is simple, but the solution may not be too simple.
An application can hold a maximum of 65534 variables, also counting all structured variables.
You have to spread out your data into programs, another application or something like that.
Do you really need all of them as global variables?