I think the link @michael.bertsch shared with you is the perfect solution for you @michal.sekerka. I would use a PYTHON script if I needed to adapt more things in the configuration. If you need that, let me know and I will give you a contact for a PYTHON expert in B&R who will help you with it
hi, @michael.bertsch is this also usable for defining global constant that is used as array index for variables? because the use case there is more simple as it is just a assignment of variable.
i am not an expert on this, i only provided a link to the other thread.
I think you would like to do this… a Define used in a .var File. → My Test showed that Automation Studio is not happy about it an throws some Errors. Also the SmartEdit marks it as red.
I’ve noticed it’s also possible to add *.var files to configs in the configuration view. I thought this is the perfect way to declare some global constants that can be used for array size definition etc.
Unfortunately, I was not able to get it working. AS Help did not give me any hints either. Probably it’s a deprecated leftover or something.
If someone got it running, I would highly appreciate any insights.
What I do not like in case of the prebuilt script is that versioned source code gets manipulated at compile time. This implies challenges.
just to give my input: Instead of working around getting the array to the proper size, maybe instead just adjust the handling of it in the code? When you can use the mechanism of compiler flags there (seems so), you can just make sure to only use the amount of array elements you need. So using Michael’s example code with the flexible MAX_IDX but defining the array itself with the maximum size you need across all configs.
So example:
Array size: 100 elements (static value, no defining involved)
Config 1: Only iterates through 20 elements, 80 unsued
Config 2: Iterates through 80, 20 unused
Config 3: Iterates through 100, 0 unused