Send a message if the text doesn't exist in the list

I want to send a message:

if the text doesn't exist in the list

in all cases, I get the message even though I put it in (else)

Use Do it for debugging

Also you should introduce a boolean variable found. Set it to true if the value was found and use another if statement outside of the loop to check that variable

If not found
Then send message

Use the companion app and Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

I'm trying to understand the topic (Do It) without the emulator.

But I can't seem to grasp it. I tried these blocks.

try it with emulator
also Do it does not work with local variables, display their value in a label to debug, for example

set Label1.Text to get value
the use Do it on a get Label1.Text block to see the value

Taifun

I'm having trouble understanding you. Could you send an image of what the blocks would look like?

Please.

unknown
Taifun

these could be your blocks assuming the value is what you are expecting, i.e. is "value" a list of lists and the first item of each sublist is the text you are looking for?

Taifun

With item, an error occurs.

With value, the message still appears even when it exists and it doesn't exist.


Show us a Do it result of value
Read again Send a message if the text doesn't exist in the list - #6 by Taifun

Taifun


equality does exist

First of all: Why are you still not using Do it?

As we can see, value is a single list and not a list of lists...
the question is, why are you using a for loop?
just remove it and use an if then else statement instead

And as the text in the textbox is 1000 and your text you are trying to get is 100, the if statement is false, so 1000 was not found, which results in your notifier "NO EXISTE" which is exactly what you were asking for

Taifun

You're right, the list doesn't exist :sweat_smile:
I just saw it.

I started this project a few days ago, but it's no longer on the forum.

Let me explain:
There should be a list of the first items (red frame).

If the text field content exists in the list, I get its label.

If it doesn't exist, it sends the message (DOES NOT EXIST).

I tried comparing the text with:

Web1
JasonTextDecode

The problem was that I couldn't compare the text with leading zeros because it didn't recognize them.

in these 2 items

Well, using Do it would help very much... you could have easily found it out yourself much earlier... instead you chose to develop with blindfolds on and are lost in the dark

Taifun

I got it.

The blue text:
is the list of the first items.

First.
I look for the label of the text field content (red).

Second.
With the label, I get items 2 and 3.

Now the problem is, when I want to type another text, it freezes.



What could I do here?

It looks like you created an endless loop

The GotValue event calls GetValue, which triggers again the GotValue event, which calls GetValue again, etc

To fix this one solution is to set a global variable to indicate, if you are tying to get

  1. the label of the text field, or
  2. item 2 and 3

and use an if then else statement in the GotValue event

Taifun

1 Like

It's working now.

The problem now is that it's not sending the message when I apply the (if else) statement.


Coming back again at the following question: what is value? Is it a list of lists?
EDIT: no

Read again from here and remove the for loop Send a message if the text doesn't exist in the list - #11 by Taifun

Taifun

Also what is list of first items? How do you get it? Use Do it to find it out

Taifun

I did it!
It's true, a loop has been created with two FirebaseDB retrievals.

The first is to get the list to compare the text field with.

The second is to get the data for the searched item.

The problem is that when I press the button several times quickly, I get the message:

What could I do?