# Is it possible to create an array of integers to store modbus values in the boolean bits of the integer?

**URL:** <https://forum.inductiveautomation.com/t/is-it-possible-to-create-an-array-of-integers-to-store-modbus-values-in-the-boolean-bits-of-the-integer/107687>\
**Category:** Ignition\
**Created:** [June 23, 2025, 6:31pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-create-an-array-of-integers-to-store-modbus-values-in-the-boolean-bits-of-the-integer/107687 "2025-06-23T18:31:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Doemdz](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Doemdz](https://forum.inductiveautomation.com/u/Doemdz)\
**Post date:** [June 23, 2025, 6:31pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-create-an-array-of-integers-to-store-modbus-values-in-the-boolean-bits-of-the-integer/107687/1 "2025-06-23T18:31:57Z")

</div>

I have setup connection with several modbus devices in my gateway. I monitor two modbus addresses from each device. I need to create a Data array of integers where I input the values of the modbus registers into the boolean bits of the integers. Each integer in the array represents a modbus device and I would like to input the values of the two registers in bit 0 and bit 1. I can easily do this on a PLC but hoping I can get some guidance on how to do this in ignition.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [June 23, 2025, 7:21pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-create-an-array-of-integers-to-store-modbus-values-in-the-boolean-bits-of-the-integer/107687/2 "2025-06-23T19:21:54Z")

</div>

There is no way to create an array via an expression. You would have to configure a gateway timer script to read all of the different device registers and assemble them into Ints, and assemble all those into an array and write it to the expected tag. Something like a 1s rate on this timer event should work for most applications.

Arrays expect a `jarray.array` type to be written to them.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 23, 2025, 8:16pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-create-an-array-of-integers-to-store-modbus-values-in-the-boolean-bits-of-the-integer/107687/3 "2025-06-23T20:16:34Z")

</div>

Hmmm. I should add `toArray()` to my toolkit.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [June 23, 2025, 8:17pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-create-an-array-of-integers-to-store-modbus-values-in-the-boolean-bits-of-the-integer/107687/4 "2025-06-23T20:17:20Z")

</div>

Please do, I tried to use `asList()` once hoping it would coerce, but no dice.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 23, 2025, 9:16pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-create-an-array-of-integers-to-store-modbus-values-in-the-boolean-bits-of-the-integer/107687/5 "2025-06-23T21:16:17Z")

</div>

> [@pturmel](#):
>
> I should add `toArray()` to my toolkit.

Tricky across primitives and generics at the same time, no? Although I'm not well versed enough in the tag system layer to know whether it'll coerce a boxed array as you'd expect it to.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 23, 2025, 10:02pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-create-an-array-of-integers-to-store-modbus-values-in-the-boolean-bits-of-the-integer/107687/6 "2025-06-23T22:02:56Z")

</div>

I would have it take two arguments, a type as is used for dataset column types, and the list to convert to an array of that type. The error when I tested with `asList()` suggests it is expecting boxed `Integer`, not `int`.
