# Check in ST if a REFERENCE is valid

**URL:** <https://community.br-automation.com/t/check-in-st-if-a-reference-is-valid/10901>\
**Category:** Programming\
**Tags:** automation-studio, structured-text\
**Created:** [April 15, 2026, 9:06am UTC](https://community.br-automation.com/t/check-in-st-if-a-reference-is-valid/10901 "2026-04-15T09:06:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samuel](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/samuel/32/155_2.png) [@Samuel](https://community.br-automation.com/u/Samuel)\
**Post date:** [April 15, 2026, 9:06am UTC](https://community.br-automation.com/t/check-in-st-if-a-reference-is-valid/10901/1 "2026-04-15T09:06:51Z")

</div>

Hi Community,

I have a project programmed in Structured Text.

There I use the following line:

```structured-text
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](https://europe1.discourse-cdn.com/brcommunity/original/2X/7/7ae273322e03c207262b2814a143c5be14674f72.png)

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

 ![image](https://europe1.discourse-cdn.com/brcommunity/original/2X/e/ee3cb9834fde2942349564a0f6222cc2298c6812.png)

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:

 ![image](https://europe1.discourse-cdn.com/brcommunity/original/2X/e/e8b5d5a3c6ded1d1ccd54107e73028d0f5c51332.png)

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?

---

<div class="post-metadata">

**Author:** ![florent.boissadier](https://avatars.discourse-cdn.com/v4/letter/f/FF8800/32.png) [@florent.boissadier](https://community.br-automation.com/u/florent.boissadier)\
**Post date:** [April 15, 2026, 10:30am UTC](https://community.br-automation.com/t/check-in-st-if-a-reference-is-valid/10901/2 "2026-04-15T10:30:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![c372196](https://avatars.discourse-cdn.com/v4/letter/c/FF8800/32.png) [@c372196](https://community.br-automation.com/u/c372196)\
**Post date:** [April 15, 2026, 11:58am UTC](https://community.br-automation.com/t/check-in-st-if-a-reference-is-valid/10901/3 "2026-04-15T11:58:27Z")

</div>

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.

> **[B&R Online Help](https://help.br-automation.com/#/en/6/ascode%2Fintroduction%2Ftroubleshooting%2Fcoding_and_editing.html)**
