[Solved] Global Variable String returns 0

In the global variables i wrote a structure, that contains numbers and strings, but when i access a child string an try to change the text of a button (label), the string is output as zero.

i tried different ways to text output of the string, and there is no mistake.
every child string of the structure and also the numbers are returned as zero.

Why is the Global structure not declared?
I think this is the problem…

Hey, can you share screenshots of the declared structure variable as well as the event for changing the label?

I tried different ways to express the child number or the child string, but it always puts out the zero, when i start it.

Remove this

If you ask why
Then this is your answer
They are 2 separate variables
image

So variable you try to print to text object simply does not exist

I am aware these are 2 different words
But i want to use it as example
Even if it was same exact word it would still be 2 different variables
You simply don’t have child with that name

I tried following:

I set the second variable to a number, then it works.But i need to set the global Variable Number in there. I tried it like this, but it still does not work…

Player_Ausrüstung is a list of numbers

I’ll use generic names for variables to explain few things, and to avoid using non-latin characters and making typos.

The expression to access a child in a structure would be:

  • Structure.Child

If you want to access a child dynamically using a variable’s value, the expression would be:

  • Structure[Variable]

The names of children in a structure are strings, whereas children in an array have indexes (numbers). Since the variable you’re using to access the structure dynamically is a number, it’s better to add ToString(). You also need to add ToString() to the whole expression because the value you’re getting and want to add to the label is a number and not a string.

So in your case, the full expression you’re looking for would be:

  • ToString(Structure[ToString(Variable)].ChildVar)

Note: you don’t need to add GlobalVariableString() since the variable is already declared.

Thank you very much. I solved it like this an got the right expression in the Label of the Button…

SOLVED !!!