If block is not working


Hi Thunkable,
I am a Student and first time user from India.
This is the sequences of operation. I am printing the values.

  1. MoveLiftTo = 12, LiftPos = 0,
  2. I call the function MoveLift. Right now MoveLiftTo is > LiftPos
  3. We go to the Do part of the If block and print Greater than
  4. We save the current Lift Position in LiftPos
  5. Everything works fine
  6. Now I set MoveLiftTo = 3
  7. Now I see it prints out MoveLiftTo = 3, LiftPos = 12
  8. Instead of going to else part it again goes to the Do part & prints Greater than
  9. I have set the keyboard to Numeric for the MoveLiftTo input & LiftPos is a app variable.
  10. Please Advice me why the if logical block is failing.
    Thank u very much,
    Regards Sneha

Hi and welcome to Thunkable!

You can’t compare text strings as numbers. So checking to see if “3” > “12” doesn’t really mean what you think it should mean. You need to convert both strings to numbers. The way to do that in Thunkable is to add zero to each one (the text input’s text and the cloud variable). Then you can compare them with logical/mathematical symbols such as >.

1 Like

Thank you very much Sir
It works perfectly. Now I know how to convert strings into numbers
Best regards
Sneha

1 Like