# Best way to write to PLC array

**URL:** <https://forum.inductiveautomation.com/t/best-way-to-write-to-plc-array/83791>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [January 4, 2024, 2:57pm UTC](https://forum.inductiveautomation.com/t/best-way-to-write-to-plc-array/83791 "2024-01-04T14:57:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [January 4, 2024, 2:57pm UTC](https://forum.inductiveautomation.com/t/best-way-to-write-to-plc-array/83791/1 "2024-01-04T14:57:33Z")

</div>

I have looked through the forum and documentation and I am not clear on what the best way to write to an OPC Item array is.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 4, 2024, 2:58pm UTC](https://forum.inductiveautomation.com/t/best-way-to-write-to-plc-array/83791/2 "2024-01-04T14:58:24Z")

</div>

Writing an array value via `system.tag.writeBlocking` is probably the easiest way.

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [January 4, 2024, 2:59pm UTC](https://forum.inductiveautomation.com/t/best-way-to-write-to-plc-array/83791/3 "2024-01-04T14:59:53Z")

</div>

So I should create two lists? Do you have an example? I have an array of 300 that I need to update.

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [January 4, 2024, 3:09pm UTC](https://forum.inductiveautomation.com/t/best-way-to-write-to-plc-array/83791/4 "2024-01-04T15:09:58Z")

</div>

Something like this?

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/6/66df951ef70f9a8508de8d18b0a05baf2d09aa7e.png)

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [January 4, 2024, 3:14pm UTC](https://forum.inductiveautomation.com/t/best-way-to-write-to-plc-array/83791/5 "2024-01-04T15:14:41Z")

</div>

That looks about right. You can also use some list comprehensions instead of the for loops to do the same thing in a more compact way.

Something like this:

> [@Best way to copy tag values from one register to another](https://forum.inductiveautomation.com/t/best-way-to-copy-tag-values-from-one-register-to-another/44069/4):
>
> One version I believe replaces all the functionality in use in the function you shared above (caveat: untested): def load\_mem\_to\_current(cell\_id): """Load recipe parameters from memory to cell/current location Param: cell\_id (str): Id designation of cell """ # List tags to read. readTags = ['[{}]/Cell/Recipe/Memory/{}'.format(cell\_id, x) for x in range(0,49)] # Read tags and extract values. writeValues = [x.value for x in system.tag.readBlocking(readTags)] # List…

---

<div class="post-metadata">

**Author:** ![Pat\_Cunningham](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pat_cunningham/32/57710_2.png) [@Pat\_Cunningham](https://forum.inductiveautomation.com/u/Pat_Cunningham)\
**Post date:** [January 4, 2024, 3:20pm UTC](https://forum.inductiveautomation.com/t/best-way-to-write-to-plc-array/83791/6 "2024-01-04T15:20:25Z")

</div>

Perfect. Thanks
