Page 1 of 1

[SOLVED] How to update a Dictionary Screen Variable?

Posted: Tue Feb 25, 2020 5:25 pm
by hell_oh_world
Hey Folks! Good Morning to all of you!

So right now I have my variables inside my screen. I structured one of my variables as a dict, unfortunately, I am unable to update it. Simply

Code: Select all

ScreenVariableInputValue
, which I use because I want to live update the variable using an input, and `SetScreenVariable`, which is another way of modifying screen variables in some cases, do not work. I mean, is it possible to use the

Code: Select all

value
property of the input element and update at the same time the dict? I've been using something like this

Code: Select all

value ScreenVariableInputValue("dict['key1']['key2']")
, unfortunately it throws an error that key is not found. Is this possible though?

Another thing... If things are not really feasible and the use of

Code: Select all

changed
property is the only solution, is there a

Code: Select all

namespace
that I can call inside my python functions or inside the python blocks itself that contains the screen variables for a specific screen? Something like

Code: Select all

screen.variables.dict["key1"]["key2"]
Hope my questions make sense. Thank you, everyone, have a good day!

Re: How to update a Dictionary Screen Variable?

Posted: Tue Feb 25, 2020 6:00 pm
by Alex

Re: How to update a Dictionary Screen Variable?

Posted: Tue Feb 25, 2020 6:20 pm
by hell_oh_world
Oh my god! Didn't see that one, this one should definitely work! Gotta try this after I get home. Thanks Alex. I'll see if this will work.

Re: How to update a Dictionary Screen Variable?

Posted: Wed Feb 26, 2020 3:15 am
by hell_oh_world
Unfortunately, I have no idea on how to use this Action... I used it something like this?

Code: Select all

value DictInputValue("inputFields", "['givenName']['value']")
But an error appears, it says "string indices must be an integer." Am I using this right? the doc is not clear on what kind of data type or parameters that the action needs, so i passed string arguments. Tried also escaping the brackets knowing that it might interpret it as a string interpolation, but no luck. Am I doing something wrong with this? Clearly I have no clue on how to use this action.

Re: How to update a Dictionary Screen Variable?

Posted: Wed Feb 26, 2020 3:21 am
by hell_oh_world
Guess I made it work! so the only string argument is the key argument and the dict argument is the actual name of the variable.

Code: Select all

value DictInputValue(inputFields["givenName"], "value")
Thanks for the help Alex!