# Codesys syntax program

**URL:** <https://www.wago.community/t/codesys-syntax-program/2685>\
**Category:** CODESYS\
**Created:** [April 17, 2026, 2:58pm UTC](https://www.wago.community/t/codesys-syntax-program/2685 "2026-04-17T14:58:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JF89](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@JF89](https://www.wago.community/u/JF89)\
**Post date:** [April 17, 2026, 2:58pm UTC](https://www.wago.community/t/codesys-syntax-program/2685/1 "2026-04-17T14:58:36Z")

</div>

Hello,

Do you know why this command with parenthesis doesn’t work

IF (arrStruct[j].R\_index\_courant)\>(arrStruct[j+1].R\_index\_courant) THEN

and this one without parenthesis **works** :

IF arrStruct[aiIndexArray[j]].R\_index\_courant \> arrStruct[aiIndexArray[j+1]].R\_index\_courant THEN

Another thing strange:

![image](https://us1.discourse-cdn.com/flex016/uploads/wago/optimized/2X/0/06b6fe83ad1d3e6582a003b577eb21263800953e_2_690x69.png)

in that program PuissABC is an int and divided with a real , and it works !! why ?

---

<div class="post-metadata">

**Author:** ![RMauldin](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@RMauldin](https://www.wago.community/u/RMauldin)\
**Post date:** [April 17, 2026, 8:23pm UTC](https://www.wago.community/t/codesys-syntax-program/2685/2 "2026-04-17T20:23:52Z")

</div>

Just guessing: Putting something inside of parenthesis may be seen by the compiler as a whole condition. In your case you have created two independent conditions separated by “\>”. Proper syntax using parenthesis (although not needed) would be …

IF (arrStruct[aiIndexArray[j]].R\_index\_courant \> arrStruct[aiIndexArray[j+1]].R\_index\_courant) THEN

---

<div class="post-metadata">

**Author:** ![JF89](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@JF89](https://www.wago.community/u/JF89)\
**Post date:** [April 18, 2026, 9:15am UTC](https://www.wago.community/t/codesys-syntax-program/2685/3 "2026-04-18T09:15:47Z")

</div>

Thanks for your explanation

---

<div class="post-metadata">

**Author:** ![WagoIcard](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagoicard/32/1508_2.png) [@WagoIcard](https://www.wago.community/u/WagoIcard)\
**Post date:** [April 20, 2026, 12:51am UTC](https://www.wago.community/t/codesys-syntax-program/2685/4 "2026-04-20T00:51:32Z")

</div>

and for the second one, codesys should give you a warning about an automatic type conversion no ?

---

<div class="post-metadata">

**Author:** ![JF89](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@JF89](https://www.wago.community/u/JF89)\
**Post date:** [April 20, 2026, 6:04am UTC](https://www.wago.community/t/codesys-syntax-program/2685/5 "2026-04-20T06:04:30Z")

</div>

Hello,

there is no warning and the program compile.

The calculation is done 1 time every each second , as you can see it below.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/wago/original/2X/e/ef1142e7ff9810e43c48d3bcc8c4f5f12f45e4de.png)

---

<div class="post-metadata">

**Author:** ![WagoIcard](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagoicard/32/1508_2.png) [@WagoIcard](https://www.wago.community/u/WagoIcard)\
**Post date:** [April 20, 2026, 6:36am UTC](https://www.wago.community/t/codesys-syntax-program/2685/6 "2026-04-20T06:36:19Z")

</div>

NRJ\_ABC is a REAL right ? if you divide a INT by a REAL, you will have an automatic conversion from the INT to REAL without any WARNING as long as the output is also a REAL.

---

<div class="post-metadata">

**Author:** ![JF89](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@JF89](https://www.wago.community/u/JF89)\
**Post date:** [April 20, 2026, 6:58am UTC](https://www.wago.community/t/codesys-syntax-program/2685/7 "2026-04-20T06:58:43Z")

</div>

thank you for the explanation ,

i didn’t know that automatic conversion.

s there any other case that automatic conversion can apply ?

word , dword and so on..

---

<div class="post-metadata">

**Author:** ![WagoIcard](https://sea2.discourse-cdn.com/flex016/user_avatar/www.wago.community/wagoicard/32/1508_2.png) [@WagoIcard](https://www.wago.community/u/WagoIcard)\
**Post date:** [April 20, 2026, 8:30am UTC](https://www.wago.community/t/codesys-syntax-program/2685/8 "2026-04-20T08:30:35Z")

</div>

Any conversion from a type to a bigger type will be without warning:  
USINT → UINT → UDINT → ULINT  
SINT → INT → DINT → LINT  
BYTE → WORD → DWORD → LWORD  
REAL → LREAL  
Also conversion from USINT→BYTE since those 2 contain the same data.  
there is maybe more than that but i can’t remember it …
