# Readblocking help

**URL:** <https://forum.inductiveautomation.com/t/readblocking-help/108482>\
**Category:** Ignition\
**Created:** [July 15, 2025, 2:18pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482 "2025-07-15T14:18:52Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [July 15, 2025, 2:18pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/1 "2025-07-15T14:18:52Z")

</div>

Hello,

I have a Tag change script where there are multiple individual tag readblocking statements and I am trying to group them together, but it doesn't seem to read.

```python
paths6 = ["[HighVol_Lower]NEQ/DINT1",
           "[HighVol_Lower]NEQ/DINT2" ]

ValuesPaths6 = system.tag.readBlocking(paths6)
current = ValuesPaths6[0].value
previous = ValuesPaths6[1].value

```

What am I doing wrong here? Please throw some light.

TIA

---

<div class="post-metadata">

**Author:** ![ryan.perretta](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.perretta/32/75110_2.png) [@ryan.perretta](https://forum.inductiveautomation.com/u/ryan.perretta)\
**Post date:** [July 15, 2025, 2:25pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/2 "2025-07-15T14:25:42Z")

</div>

> [@Sweetz](#):
>
> but it doesn't seem to read.

What do you mean by this? Are you getting an error when the tag change script executes or are the results not what you are expecting?

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [July 15, 2025, 2:27pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/3 "2025-07-15T14:27:25Z")

</div>

The script executes based on these two values not being equal and clearly the script does not seem to run because these values haven't been updated

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 15, 2025, 2:31pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/4 "2025-07-15T14:31:44Z")

</div>

You need to show your entire script.

There is nothing syntactially incorrect in the snipit that you included in the OP

---

<div class="post-metadata">

**Author:** ![ryan.perretta](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.perretta/32/75110_2.png) [@ryan.perretta](https://forum.inductiveautomation.com/u/ryan.perretta)\
**Post date:** [July 15, 2025, 2:31pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/5 "2025-07-15T14:31:48Z")

</div>

Are you positive that the tag change script is being triggered and actually executing? If not I'd add some logging in to be sure.

Also, it would be helpful if you could share the entire tag change script. I don't see anything wrong with the snippet you shared, the issue you are having could be due to something else.

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [July 15, 2025, 2:42pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/6 "2025-07-15T14:42:05Z")

</div>

```python
'''
current = system.tag.readBlocking('[HighVol_Lower]NEQ/Sta32_BarcodeDINT_Current')
previous = system.tag.readBlocking('[HighVol_Lower]NEQ/Sta32_CamStoredPrevious')
section = system.tag.readBlocking("[HighVol_Lower]User_Interface/Sta32_User/Layer_Insert")
section_pos = system.tag.readBlocking("[HighVol_Lower]User_Interface/Sta32_User/Layer_pos_Insert")
part_pos = system.tag.readBlocking("[HighVol_Lower]User_Interface/Sta32_User/Stack_pos_Insert")
pallet = system.tag.readBlocking('[HighVol_Lower]User_Interface/Sta32_User/PalletID_Insert')
'''
ID = system.tag.readBlocking("[HighVol_Lower]User_Interface/Sta32_User/DEMO_Serial")
sta = "32"
timestamp = system.tag.readBlocking("[HighVol_Lower]Time_Stamp")

paths6 = ['[HighVol_Lower]NEQ/Sta32_BarcodeDINT_Current',
           '[HighVol_Lower]NEQ/Sta32_CamStoredPrevious',
           '[HighVol_Lower]User_Interface/Sta32_User/Layer_Insert',
           '[HighVol_Lower]User_Interface/Sta32_User/Layer_pos_Insert',
           '[HighVol_Lower]User_Interface/Sta32_User/Stack_pos_Insert',
           '[HighVol_Lower]User_Interface/Sta32_User/PalletID_Insert']
			
ValuesPaths6 = system.tag.readBlocking(paths6)
current = ValuesPaths6[0].value
previous = ValuesPaths6[1].value
section = ValuesPaths6[2].value
section_pos = ValuesPaths6[3].value
part_pos = ValuesPaths6[4].value
pallet = ValuesPaths6[5].value 

import time

if current[0].value != previous[0].value:
	if current[0].value != 0:
		
	 start = system.tag.readBlocking('[HighVol_Lower]Bar Grade/Sta32_BarcodeGrade')
	 if start[0].value > 2:
		system.tag.writeBlocking(['[HighVol_Lower]Start_Text/Sta32_Cam02_Pass'], [0])
		barcode = system.tag.readBlocking('[HighVol_Lower]Camera_Data/Sta32Cam_I_Data')
	
		if barcode[0].value[:16] > 0:
			query = "SELECT COUNT(data) FROM barcodes_data WHERE data = ?"
			count = system.db.runScalarPrepQuery(query, [barcode[0].value[:16]])
			if count < 1:
			 Number_String = system.tag.readBlocking('[HighVol_Lower]Camera_Data/Sta32Cam_I_Data')
			 julian = Number_String[0].value[2:7]
			 StaNO = 32
		 	 query = "INSERT INTO barcodes_data(data, Julian_Date, Station) VALUES (?,?,?)"
			 system.db.runPrepUpdate(query, [barcode[0].value[:16], julian, StaNO])
		 	 system.tag.writeBlocking(['[HighVol_Lower]Script_Pass/Sta32_EntryScan_Complete'], [1])

```

So, I just commented out the readblocking group that I have issues with and ran with individual readblockings and it works. When I activate the readblocking group, the script doesn't run and return the last writeblocking bit that I monitor in PLC. @lrose @ryan.perretta

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 15, 2025, 2:53pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/7 "2025-07-15T14:53:04Z")

</div>

When you say tag change script do you mean Tag Value Change Script (on the tag itself), or Gateway Tag Change Script (In the Project).

There are a number of things that I might change depending on the answer to that question.

---

<div class="post-metadata">

**Author:** ![ryan.perretta](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.perretta/32/75110_2.png) [@ryan.perretta](https://forum.inductiveautomation.com/u/ryan.perretta)\
**Post date:** [July 15, 2025, 2:55pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/8 "2025-07-15T14:55:26Z")

</div>

When you changed this to reading all the tags as a group you are pulling out the tags from the returned array of Qualified Values and pulling the value from the QV at the top here:

> [@Sweetz](#):
>
> ```python
> current = ValuesPaths6[0].value
> previous = ValuesPaths6[1].value
> section = ValuesPaths6[2].value
> section_pos = ValuesPaths6[3].value
> part_pos = ValuesPaths6[4].value
> pallet = ValuesPaths6[5].value 
> 
> ```

Then it seems you are doing it again in the first `if` statement here:

> [@Sweetz](#):
>
> `if current[0].value != previous[0].value:`

I suspect this would be causing some issues.

You will need to make some changes to the block of code beneath the grouped tag read to address this. In the example I provided I believe your `if` statement should read

```py
if current != previous:
 ......

```

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [July 15, 2025, 2:59pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/9 "2025-07-15T14:59:17Z")

</div>

Gateway tag change script. I monitor Cam\_I\_Data to run the script on a change

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [July 15, 2025, 3:14pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/10 "2025-07-15T15:14:09Z")

</div>

@ryan.perretta That did the trick. It's the qualified values being called again causing issues.

I have lot of other script down below using syntax like 'part\_pos[0].value'. I have to figure out a way to clean up assuming this group readblocking saves lot of script execution time.

Thank you!

---

<div class="post-metadata">

**Author:** ![ryan.perretta](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.perretta/32/75110_2.png) [@ryan.perretta](https://forum.inductiveautomation.com/u/ryan.perretta)\
**Post date:** [July 15, 2025, 3:18pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/11 "2025-07-15T15:18:40Z")

</div>

Basically, anywhere you use these variables that you define at the top you can drop the `[0].value` off the end because you have already taken that step when initializing them.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 15, 2025, 3:18pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/12 "2025-07-15T15:18:46Z")

</div>

Ok, good, otherwise the database operations would not have been good.

1. It appears you may be mixing tabs and spaces. Technically this is allowed so long as it is syntactically consitent, however, it will bite you when you least expect it so it's best to choose one and go with that.  

2. You should do all of your reads at the start of the script, and all of your writes at the end. Which is perhpas what you're working towards. There are some arguments for having separate writes, when you need. I would ask, is there any reason you would want to write the Pass, without writing Complete?

3. You can use a list comprehension to extract the values from the List of Qualified Values, and then unpack those directly into variables. This will make things more readable (IMO).

4. Do not import packages inside of functions, especially if you're not using them.

5. You should move this script to a Library Function, so you can avoid the Legacy Scoping issues that come with Gateway Event Scripts.

Here is how I would write your script:

```python
readPaths = ['[HighVol_Lower]User_Interface/Sta32_User/DEMO_Serial',
			'[HighVol_Lower]NEQ/Sta32_BarcodeDINT_Current',
        	'[HighVol_Lower]NEQ/Sta32_CamStoredPrevious',
        	'[HighVol_Lower]User_Interface/Sta32_User/Layer_Insert',
        	'[HighVol_Lower]User_Interface/Sta32_User/Layer_pos_Insert',
        	'[HighVol_Lower]User_Interface/Sta32_User/Stack_pos_Insert',
        	'[HighVol_Lower]User_Interface/Sta32_User/PalletID_Insert',
        	'[HighVol_Lower]Time_Stamp',
        	'[HighVol_Lower]Bar Grade/Sta32_BarcodeGrade',
        	'[HighVol_Lower]Camera_Data/Sta32Cam_I_Data']
			
userID,barcodeCur,storedPrev,section,sectionPos,partPos,pallet,timestamp,start,barcode = [qv.value for qv in system.tag.readBlocking(readPaths)]

if barcodeCur != storedPrev:
	if barcodeCur:
		
	 if start > 2:
		system.tag.writeBlocking(['[HighVol_Lower]Start_Text/Sta32_Cam02_Pass'], [0])
			
		if barcode[:16] > 0:
			query = "SELECT COUNT(data) FROM barcodes_data WHERE data = ?"
			count = system.db.runScalarPrepQuery(query, [barcode[:16]])
			if count < 1:
			 julian = barcode[2:7]
			 StaNO = 32
		 	 query = "INSERT INTO barcodes_data(data, Julian_Date, Station) VALUES (?,?,?)"
			 system.db.runPrepUpdate(query, [barcode[:16], julian, StaNO])
		 	 system.tag.writeBlocking(['[HighVol_Lower]Script_Pass/Sta32_EntryScan_Complete'], [1])

```

---

<div class="post-metadata">

**Author:** ![Sweetz](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Sweetz](https://forum.inductiveautomation.com/u/Sweetz)\
**Post date:** [July 15, 2025, 3:44pm UTC](https://forum.inductiveautomation.com/t/readblocking-help/108482/13 "2025-07-15T15:44:01Z")

</div>

Thank you @lrose. It has already bitten me and keeps biting whenever I try stuff like this on the existing script lol

Point 2: I am writing a '0' to Cam Pass bit that's set in PLC and does some data moving.

Point 4,5: I am very new to Ignition and have to start learning more. What I am doing now is to support production.
