# Write 2 diff values of the same property inside a script

**URL:** <https://forum.inductiveautomation.com/t/write-2-diff-values-of-the-same-property-inside-a-script/5856>\
**Category:** Ignition\
**Created:** [February 12, 2013, 9:39pm UTC](https://forum.inductiveautomation.com/t/write-2-diff-values-of-the-same-property-inside-a-script/5856 "2013-02-12T21:39:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [February 12, 2013, 9:39pm UTC](https://forum.inductiveautomation.com/t/write-2-diff-values-of-the-same-property-inside-a-script/5856/1 "2013-02-12T21:39:01Z")

</div>

I try to write a property of a component to the value 1  
on the start of a button action performed script,  
and to the value 0 at the end.

This component is used for displaying a wait message.

The value stay to 0, and the message is not displayed.  
Is it possible to write 2 different values of the same property, or of a same client tag,  
inside the same script ?

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [February 13, 2013, 12:19am UTC](https://forum.inductiveautomation.com/t/write-2-diff-values-of-the-same-property-inside-a-script/5856/2 "2013-02-13T00:19:13Z")

</div>

Are those 0 and 1 values the value that determines if the message is showing or not? Are you trying to display the wait message for a set period of time? What exactly are you trying to do with the message box?

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [February 13, 2013, 8:10am UTC](https://forum.inductiveautomation.com/t/write-2-diff-values-of-the-same-property-inside-a-script/5856/3 "2013-02-13T08:10:14Z")

</div>

Yes the value determine if the label message is visible or not, the code is the following :

[code]import app.commun  
import app.bdd  
import system

event.source.parent.getComponent(‘LabelWait’).visible = 1  
event.source.componentEnabled=0

# liste des tables PG

sql = “SELECT TABLE\_NAME FROM INFORMATION\_SCHEMA.TABLES where table\_type=‘TABLE’ order by TABLE\_NAME asc”  
result = system.db.runQuery(sql,dbfrontal)

listeCpt = []  
for res in result:  
nom\_table = res[0]  
cpt = system.db.runScalarQuery("SELECT COUNT(\*) FROM " + nom\_table,dbfrontal)  
listeCpt.append([nom\_table,cpt]);

sql = “SELECT TABLE\_NAME FROM INFORMATION\_SCHEMA.TABLES where table\_type=‘VIEW’ order by TABLE\_NAME asc”  
result = system.db.runQuery(sql,dbfrontal)  
for res in result:  
nom\_table = res[0]  
listeCpt.append([nom\_table,0]);

headers = [“Table”, “Nombre Enregistrements”]  
result = system.dataset.toDataSet(headers,listeCpt)  
event.source.parent.getComponent(‘Table’).data = result

event.source.componentEnabled=1  
event.source.parent.getComponent(‘LabelWait’).visible = 0[/code]

```auto
import system

event.source.parent.getComponent('LabelWait').visible = 1
event.source.componentEnabled=0

... long duration process....

event.source.componentEnabled=1
event.source.parent.getComponent('LabelWait').visible = 0
```

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [February 13, 2013, 4:19pm UTC](https://forum.inductiveautomation.com/t/write-2-diff-values-of-the-same-property-inside-a-script/5856/4 "2013-02-13T16:19:15Z")

</div>

I do this in two parts. In the action script attached to the button I change the cursor to the wait one first and then I call the long running script.

At the end of the script I restore the cursor with system.util.invokeLater()

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [February 13, 2013, 8:13pm UTC](https://forum.inductiveautomation.com/t/write-2-diff-values-of-the-same-property-inside-a-script/5856/5 "2013-02-13T20:13:35Z")

</div>

Thanks Robert.

I found a similar solution in the doc :

[code]def longProcess(rootContainer = event.source.parent):

```
import system

```

…

```
# Now we'll send our results back to the UI
def sendBack(result = result,rootContainer = rootContainer):
	import system		
	rootContainer.getComponent('Table').data = result
	system.tag.write("[Client]busy",0)
system.util.invokeLater(sendBack)

```

system.tag.write("[Client]busy",1)  
system.util.invokeAsynchronous(longProcess)[/code]

the only drawback is the use of sendback method which is a bit tricky to integrate in existing code

---

<div class="post-metadata">

**Author:** ![James.Lorenz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/james.lorenz/32/3290_2.png) [@James.Lorenz](https://forum.inductiveautomation.com/u/James.Lorenz)\
**Post date:** [February 13, 2013, 11:16pm UTC](https://forum.inductiveautomation.com/t/write-2-diff-values-of-the-same-property-inside-a-script/5856/6 "2013-02-13T23:16:45Z")

</div>

Yeah, I was going to suggest invokeAsynchronous/invokeLater - essential if you’re trying to work with both long-running tasks and the UI.
