About "true" and "false" - and a trap I fell into

I learned something today that I would like to share with you here if someone has the same problem to solve. I used the variable block when setting a “true” value - which did not work. @jared then put me on the right track. Once I “typed” the variable as text, everything worked as expected.

I have put together the following example where you can see the problem, the difference and the solution:

Szenario 1: Built with variable-block, which did not work:

Szenario 1 Result:
grafik

Solution / Szenario 2: Built with text-block, which worked fine:

Szenario 2 Result:

grafik

Thanks again to Jared! Hope that someone else can use this learning experience ;).

3 Likes

What?! That is bizarre. I understand that it’s probably best not to use logic values as output strings (set label text to true/false) but I’m confused as to why the switch to a “typed” variable worked. I’m honestly not even sure what that variable block is for… does anyone use them regularly?

I’m curious – and I guess I could just test it – what would happen if instead of displaying the true/false value in the first screenshot, you just did if value=true display text string “true” else display text string “false”. I assume that would work.

1 Like

It allows for dynamic variable names!

1 Like

So I did realize that but anything else? Any idea why it works in this particular case?

if you change Varcompare type stored instead of app, you haven’t a problem.

1 Like

Which does not make it any less bizarre, to use @tatiang 's words ;).

For me this is a case of “I now know how to do it” - but I don’t find it really logical and conclusive. That is the reason why I posted it here. Alone I would probably have searched for days.

This is expected. @migo used a dynamic variable block to set a named variable which does not work.

If you go back to the first block that does not work and look carefully you will see [set app] which is used for dynamic variable setting but then he used the variable block [app VarCompare].

He should have set the variable [app VarCompare] by selecting the block from the variable drawer directly without the need to contain it inside a [set app] block.

Anyway, this means you can reference the same variable either directly from the variable drawer or dynamically through named variables but each has its own way.

2 Likes

@muneer66 Oh! You’re right!

“set app [app VarCompare]” actually takes the value of the variable “app VarCompare” and uses it as the variable name in the “set app” block. For example, if “app VarCompare” had the value ‘true’, then “set app [app VarCompare]” is evaluated as "set app ‘true’ " where ‘true’ is the name of the variable.

Confusing, to say the least, but expected behavior now that I understand it better.

3 Likes

Thank you for making it even clearer and easier to understand :clap:

2 Likes