Check in ST if a REFERENCE is valid

Hi Community,

I have a project programmed in Structured Text.

There I use the following line:

DiagMC_BR_ShReadInfo_0[i].Enable := NOT DiagMC_BR_ShReadInfo_0[i].Error AND ShAxis[i].controlif <> 0;

ShAxis/controlif is defined like this:

image

When I check ShAxis[i] in the Watch it looks like this:

So controlif is a reference to another datatype, but internally in the variable only the address is saved as UDINT.

This line of code works in AS 6, but AS Code rightfully complains about this line:

My question is:

It works, but it’s really not very elegant. How can this be implemented better in ST? How can I check if a reference is valid?

Hi @Samuel

From my point of view, it’s the correct way to do it, I think it’s more about the syntax checker in AS Code, Dynamic variable are considered as UDINT during runtime, but in the variable declaration it’s another type.

Maybe you could report this to your local B&R Office!

Regards,
Florent

HI,

Structured Text - Reference variables not yet supported

Reference variables (REFERENCE TO) are not yet supported by AS Code. If references are used, they are displayed as invalid syntax.