PeterW
Member
Having issues finding how to have a variable tag as an array offset, when that array is part of the FB STAT area and the array is being passed into an FC.
Basically I have a master FB, from that FB I am calling the same FB twice unconditionally, ie I am sharing the masters DB. Each call is for one of two identical areas. I have a STAT INT tag, Track, which I write a 1 or 2 into before the UC call.
The STAT area has a two UDT tags, each an array[1..2], in these UDTs are all the data needed for the areas. One is called sCalcs, so I have sCalcs[1] and sCalcs[2].
Within the UDT I have a number of tags, including other UDT's. One of these UDT's is a 4 point UDT, ARRAY[1..4] or REAL, called inflight.
So I have sCalcs[1].Inflight[1] all the way up to sCalcs[2].Inflight[4]
Inside the second FB, I call an FC programmed in SCL and I pass a number of tags in and out, a few need offsetting to the correct array, the one I showed above is one.
the problem I get, is it allows me to directly program the offset #sCalcs[1].Inflight as a parameter into the FC, but won't allow #sCalcs[#Track].Inflight, it says syntax error.
I have tried creating a TEMP Int and passing the offset, Track, into that, then use the Temp. Same error.
I've tried different formats of pointer DINT, WORD, nothing works. I can only program the direct offset.
I'm beginning to think there is no way, hopefully someone can show me a solution and let me know why you cannot do this.
I'm trying not to use ANY pointers, I have made alternative logic this way, I'm trying to keep it simple for the others who will use this logic.
Basically I have a master FB, from that FB I am calling the same FB twice unconditionally, ie I am sharing the masters DB. Each call is for one of two identical areas. I have a STAT INT tag, Track, which I write a 1 or 2 into before the UC call.
The STAT area has a two UDT tags, each an array[1..2], in these UDTs are all the data needed for the areas. One is called sCalcs, so I have sCalcs[1] and sCalcs[2].
Within the UDT I have a number of tags, including other UDT's. One of these UDT's is a 4 point UDT, ARRAY[1..4] or REAL, called inflight.
So I have sCalcs[1].Inflight[1] all the way up to sCalcs[2].Inflight[4]
Inside the second FB, I call an FC programmed in SCL and I pass a number of tags in and out, a few need offsetting to the correct array, the one I showed above is one.
the problem I get, is it allows me to directly program the offset #sCalcs[1].Inflight as a parameter into the FC, but won't allow #sCalcs[#Track].Inflight, it says syntax error.
I have tried creating a TEMP Int and passing the offset, Track, into that, then use the Temp. Same error.
I've tried different formats of pointer DINT, WORD, nothing works. I can only program the direct offset.
I'm beginning to think there is no way, hopefully someone can show me a solution and let me know why you cannot do this.
I'm trying not to use ANY pointers, I have made alternative logic this way, I'm trying to keep it simple for the others who will use this logic.