# \[SOLVED\] Labels with data

**URL:** <https://forum.inductiveautomation.com/t/solved-labels-with-data/64256>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [September 19, 2022, 11:06pm UTC](https://forum.inductiveautomation.com/t/solved-labels-with-data/64256 "2022-09-19T23:06:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esmeralda\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Esmeralda\_Lopez](https://forum.inductiveautomation.com/u/Esmeralda_Lopez)\
**Post date:** [September 19, 2022, 11:06pm UTC](https://forum.inductiveautomation.com/t/solved-labels-with-data/64256/1 "2022-09-19T23:06:38Z")

</div>

Hello everyone,

I have this code and before the prints, I want to show the value of the two tags (tgCanal and tgSector) in case of the tag pathCanal has a value and then show it the label lblCanalTag and lblSectorTag but is not working.

```auto
pathCanal="[default]app_tags/Componentes/ArranquePedidos/Alarma_Canal_Vacio"
pathSector="[default]app_tags/Componentes/ArranquePedidos/Alarma_Sector_Vacio"

if pathCanal:
	system.nav.centerWindow('User Management/mensajeAlarma')

	lblCanalTag = system.gui.getParentWindow(event).getComponentForPath('Root Container.lblCanalTag')
	lblSectorTag = system.gui.getParentWindow(event).getComponentForPath('Root Container.lbSectorTag')
	
	tgCanal = system.tag.readBlocking("[default]app_tags/Componentes/ArranquePedidos/Alarma_Canal_Vacio")
	tgSector = system.tag.readBlocking("[default]app_tags/Componentes/ArranquePedidos/Alarma_Sector_Vacio")
	
	lblCanalTag=tgCanal
	lblSectorTag=tgSector
	
	print lblCanalTag
	print lblSectorTag

```

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [September 20, 2022, 2:31pm UTC](https://forum.inductiveautomation.com/t/solved-labels-with-data/64256/2 "2022-09-20T14:31:58Z")

</div>

Some thoughts:

1. Where is this script running? There are lots of places scripts can be run, but only a few places that can interact with vision windows.
2. Right now your if statement on line 4 will always be true because you’re not reading the value of a tag.
3. It’s more efficient to do all your tag reads at once.
4. system.tag.readBlocking returns a list of QualifiedValues.  
a. To read one path, you do this:  
`system.tag.readBlocking(["[default]tagFolder/tagName")[0].value`
5. Every component has properties. You can’t just write a value to a component. You have to write to the appropriate property.

If your tagpaths aren’t dynamic, maybe something like this:

```auto
pathCanal="[default]app_tags/Componentes/ArranquePedidos/Alarma_Canal_Vacio"
pathSector="[default]app_tags/Componentes/ArranquePedidos/Alarma_Sector_Vacio"

canalValue,sectorValue = system.tag.readBlocking(
	[pathCanal,pathSector]
)
if canalValue.value:
	system.nav.centerWindow('User Management/mensajeAlarma')

	lblCanalTag = system.gui.getParentWindow(event).getComponentForPath('Root Container.lblCanalTag')
	lblSectorTag = system.gui.getParentWindow(event).getComponentForPath('Root Container.lbSectorTag')
	
	# these will only be correct if this type of component has a value property.
	# lblCanalTag.text would also be something to try.
	lblCanalTag.value=canalValue.value
	lblSectorTag.value=sectorValue.value
	
	print canalValue.value
	print sectorValue.value

```

Edits: @pascal.fragnoud caught some mistakes.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [September 20, 2022, 2:39pm UTC](https://forum.inductiveautomation.com/t/solved-labels-with-data/64256/3 "2022-09-20T14:39:09Z")

</div>

> [@zacht](#):
>
> ```auto
> # these will only be correct if this type of component has a value property.
> # lblCanalTag.text would also be something to try.
> lblCanalTag.value=tgCanal
> lblSectorTag.value=tgSector
> 
> ```

This will never be correct, there are no objects called `tgCanal` and `tgSector`.  
Why did you duplicate the tags paths ?

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [September 20, 2022, 2:46pm UTC](https://forum.inductiveautomation.com/t/solved-labels-with-data/64256/4 "2022-09-20T14:46:12Z")

</div>

> [@pascal.fragnoud](#):
>
> Why did you duplicate the tags paths ?

I wasn't paying good enough attention. Thanks.

---

<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:** [September 20, 2022, 2:49pm UTC](https://forum.inductiveautomation.com/t/solved-labels-with-data/64256/5 "2022-09-20T14:49:16Z")

</div>

Assuming that `lblCanalTag` and `lblSectorTag` are actually label components, you need to assign the the tag values to the `text` property.

```auto
tagPaths = ['[default]app_tags/Componentes/ArranquePedidos/Alarma_Canal_Vacio','[default]app_tags/Componentes/ArranquePedidos/Alarma_Sector_Vacio']
tgCanal, tgSector = [qval.value for qval in system.tag.readBlocking(tagPaths)]

if tgCanal:
    system.nav.centerWindow('User Management/mesajeAlarma')

    system.gui.getParentWindow(event).getComponentForPath('Root Container.lblCanalTag').text = tgCanal
    system.gui.getParentWindow(event).getComponentForPath('Root Container.lbSectorTag').text = tgSector

```

However, this kind of makes me wonder why you aren’t just binding the labels to the tags?

---

<div class="post-metadata">

**Author:** ![Esmeralda\_Lopez](https://avatars.discourse-cdn.com/v4/letter/e/fbc32d/32.png) [@Esmeralda\_Lopez](https://forum.inductiveautomation.com/u/Esmeralda_Lopez)\
**Post date:** [September 20, 2022, 4:29pm UTC](https://forum.inductiveautomation.com/t/solved-labels-with-data/64256/7 "2022-09-20T16:29:20Z")

</div>

Thanks both, it worked
