I am struggling in the macro manager trying to perform a MIN() and MAX() command. I have 5 PLC tags that I need to determine the minimum value of all 5 tags. I have read through the support document and tried a variety of different macro codes but I either get a syntax error on the array definition line or the macro doesn’t give the correct result.

The value of the tags in the array change from time to time so the minimum value will forever change. I’m not as well versed in macros, thanks!

*To clarify, for the moment I am forcing the values of A thru E with int A=1, B=2, C=3, D=4, E=5 just to get the macro working. Once it works I will used a GET() function to pull the actual tag value to each variable.

My next question on the same note is as you can see above index 2 and 3 are 0 so the MIN()expression will always result in 0 so long as any value in array is 0. How would I go about doing a MIN()>0 function?

Again, the real scenario for this macro the array is not constant and each index points to a GetData() expression for the values.

In the example above I need the MIN() RESULT value to be 10 as it is the lowest value greater than 0.