# Accessing the PyDictionary

**URL:** <https://forum.inductiveautomation.com/t/accessing-the-pydictionary/1898>\
**Category:** Ignition\
**Created:** [June 4, 2010, 7:48pm UTC](https://forum.inductiveautomation.com/t/accessing-the-pydictionary/1898 "2010-06-04T19:48:13Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Garrickr](https://avatars.discourse-cdn.com/v4/letter/g/4491bb/32.png) [@Garrickr](https://forum.inductiveautomation.com/u/Garrickr)\
**Post date:** [June 4, 2010, 7:48pm UTC](https://forum.inductiveautomation.com/t/accessing-the-pydictionary/1898/1 "2010-06-04T19:48:13Z")

</div>

I am using the:

system.util.retarget(“APPNAME”,“SERVERNAME:8088:8043/main”,{‘value1’:param1,‘value2’:param2,‘value3’:param3},[“SCREENNAME”])

to jump between apps, I noticed in the help files that it says:

You can pass any information to the other project through the parameters dictionary. All entries in this dictionary will be set in the global scripting namespace in the other project. Even if you don’t specify any parameters, the system will set the variable \_RETARGET\_FROM\_PROJECT to the name of the current project and \_RETARGET\_FROM\_GATEWAY to the address of the current Gateway.

it uses the:  
PyDictionary params - A dictionary of parameters that will be passed to the new project. They will be set as global variables in the new project’s Python scripting environment. [optional]

how do I access these in the second app when it is opened? I tried using:

system.tag.writeToTag("[Client]value1",‘value1’)  
system.tag.writeToTag("[Client]value2",‘value2’)  
system.tag.writeToTag("[Client]value3",‘value3’)

under the gateway scripting to get the values, but it is not working.

thanks!

edit: Just tried using the direct tags: \_RETARGET\_FROM\_GATEWAY and \_RETARGET\_FROM\_PROJECT on the event handler, but \_RETARGET\_FROM\_GATEWAY only contains: SERVERNAME:8088:/main, sans 8043, so that will not work directly. Also this only gets my return target, not any other params I am passing.

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [June 4, 2010, 9:54pm UTC](https://forum.inductiveautomation.com/t/accessing-the-pydictionary/1898/2 "2010-06-04T21:54:28Z")

</div>

The PyDictionary you pass in does not create tag values, you must access them from a python script. To do so, you have to declare the globals in your script before you can use them, ie:

`global value1
global value2
total = value1 + value2
print total`

Also, what version are you using? This retarget code works for me in 7.1.1:

[code]global \_RETARGET\_FROM\_PROJECT  
global \_RETARGET\_FROM\_GATEWAY

# \_RETARGET\_FROM\_GATEWAY is formatted like ‘[http://10.1.10.1:8088/main](http://10.1.10.1:8088/main)’, so you have to remove the first 7 characters

system.util.retarget(\_RETARGET\_FROM\_PROJECT, \_RETARGET\_FROM\_GATEWAY[7:])[/code]

---

<div class="post-metadata">

**Author:** ![Garrickr](https://avatars.discourse-cdn.com/v4/letter/g/4491bb/32.png) [@Garrickr](https://forum.inductiveautomation.com/u/Garrickr)\
**Post date:** [June 4, 2010, 10:10pm UTC](https://forum.inductiveautomation.com/t/accessing-the-pydictionary/1898/3 "2010-06-04T22:10:54Z")

</div>

[quote=“Robert.McKenzie”]The PyDictionary you pass in does not create tag values, you must access them from a python script. To do so, you have to declare the globals in your script before you can use them, ie:

`global value1
global value2
total = value1 + value2
print total`

Also, what version are you using? This retarget code works for me in 7.1.1:

[code]global \_RETARGET\_FROM\_PROJECT  
global \_RETARGET\_FROM\_GATEWAY

# \_RETARGET\_FROM\_GATEWAY is formatted like ‘[http://10.1.10.1:8088/main](http://10.1.10.1:8088/main)’, so you have to remove the first 7 characters

system.util.retarget(\_RETARGET\_FROM\_PROJECT, \_RETARGET\_FROM\_GATEWAY[7:])[/code][/quote]

I am running the latest dev version(7.1.2.5230-beta5).

per conversations with Travis,

Ignition cannot resolve or find the gateway with hostname ‘SERVERNAME’. The address should look like SERVERNAME:8088:8043/main and you may want to use the IP address instead. Let me know if this fixes it.

It did not work until I added the 8043 after the 8088, and by default the \_RETARGET\_FROM\_GATEWAY does not contain this.

also, I tried declaring them in a startup script and writing them using writeToTag, it did not work for me.

thanks

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [June 4, 2010, 10:57pm UTC](https://forum.inductiveautomation.com/t/accessing-the-pydictionary/1898/4 "2010-06-04T22:57:33Z")

</div>

OK, so here is the code I am using to test this. I have a client tag called “New Tag” that I will be writing to.  
On project 1’s retarget button:

```auto
system.util.retarget("IADemo", "192.168.1.145:8088/main", {"value":5})
```

On Project 2’s Client Event Script (Startup):

`global value
system.tag.writeToTag("[Client]New Tag", value)`  
You can drop ‘New Tag’ onto your window to see that the new value is passed in.

---

<div class="post-metadata">

**Author:** ![Garrickr](https://avatars.discourse-cdn.com/v4/letter/g/4491bb/32.png) [@Garrickr](https://forum.inductiveautomation.com/u/Garrickr)\
**Post date:** [June 7, 2010, 4:22pm UTC](https://forum.inductiveautomation.com/t/accessing-the-pydictionary/1898/5 "2010-06-07T16:22:39Z")

</div>

I tried your procedure almost verbatim, but it did not work. My retarget will not work without the addtional 8043 (SSL Port), and the variable when declared globally and set to a client tag will not display on the screen. Not sure what else to try to see if the data is making it across.

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [June 7, 2010, 6:25pm UTC](https://forum.inductiveautomation.com/t/accessing-the-pydictionary/1898/6 "2010-06-07T18:25:12Z")

</div>

You can throw a print statement in there to see if the value is coming across. You can access the console by going to Help -\> Diagnostics -\> Console

`global value
print value
system.tag.writeToTag("[Client]New Tag", value)`

---

<div class="post-metadata">

**Author:** ![Garrickr](https://avatars.discourse-cdn.com/v4/letter/g/4491bb/32.png) [@Garrickr](https://forum.inductiveautomation.com/u/Garrickr)\
**Post date:** [June 7, 2010, 6:52pm UTC](https://forum.inductiveautomation.com/t/accessing-the-pydictionary/1898/7 "2010-06-07T18:52:56Z")

</div>

Got it to work, I had mistakenly put the script under the gateway script instead of the client script, and that fixed all the problems.

Thanks!
