Accessing the PyDictionary

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.

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’, so you have to remove the first 7 characters

system.util.retarget(_RETARGET_FROM_PROJECT, _RETARGET_FROM_GATEWAY[7:])[/code]

[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’, 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

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:

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.

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.

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)

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!