Thunkable if component not working

Hi guys,
I am facing a problem of the if component here.
Last night, I tried to program something that will test if the number is 1,2,3,4,5,6,7,8,9, or not, if it is a number from 1-9 then it will join 0 and the number together. However, after trying and changing the program for multiple times, I was unable to achieve it so I thought it was my problem.
Now I’m writing the program for something else. Basically, I got a list viewer and on item click I get a variable storing the item and a variable storing the index. in the item I get the name of a website, and im trying to set if the index is 1 then ill show the info of the website of maybe thunkable and if its 2 then I show the info of thunkable community.
to make the long story short, I ended up failing to do it with the if component, but succeeded with the test, if true if false component.
based on this, im guessing there’s something wrong with the if component. anyone got any guesses on what to do? thank you !

1 Like

Can you show your code?

You are talking about 1,2,3… Which in computer language can be both text and number. So if you happen to obtain 1 or 2 or 3 coded as text but you are comparing it to a number then yes, it will fail regardless of both looking very similar. Strings are not numbers.

Hope this makes it a bit clearer.

1 Like

thank you for your suggestion, and i already tried it before but it doesn’t work

here are my codes:
the first 2 shows the code i use for yesterday. i am trying to make a mood tracker. there’s a list viewer and you can add stuff. when add new item (in pic 2), i insert a date in front of the things the user inputs. but as thunkable shows january as 1 but october as 10, if i want to show what he wrote when item click on list viewer, it might have some data got from the date. that’s why im trying to add a 0 in front. i tried various methods and the one i show on the screen works. but if the day of month is a single unit number, it still doesn’t work. i tried using text, integer, does _ contain and many more but it still doesn’t work… however, the weirdest thing is when i try to debug by let’s say if app variable current month = 1 then in label show jan, it works, but when i do it to all months it does not. that makes me stuck :frowning: so basically the biggest problem is when i just do one if its fine for a few live tests then it just goes back to the original way OR when i do the same to all choices, it just goes back to the original name…

these 2 screenshots are from the code i did today, basically, i got a page with a list of website names and on item click, i show the name, info, and link of the website, also trying out the web viewer component. however, when i say if the index (which is the number of the selected item) = 1 then show these in my labels it doesn’t work, but when i put them in the test if true if false component seen at the top, it works! but i can’t do it for all 10 choices, so im stuck again. I even tried to use if heading label contains e.g. “o”, it still does not work, but works for the test if true if false.

i’m not sure if its my problem or its thunkable but the if component seems to be acting weird. thank you!

1 Like

Did I understand you correctly that you are saying in screen mood tracker add using open event, the condition if [app variable index] = 2 works but when you put if [app variable index] < 10 does not work?

In the other hand, the way you are using screen reference links 2 is not the proper way. It is much better to create 2 lists one has the names of organisations and the other has the URL to the corresponding entry in the first list.

This way, you show the names list and when the user selects then you use the index to get the corresponding URL from the second list and you will not need all the if conditions in the code.

I did not understand the use of forever loops so will not comment on it for the time being.