Search code examples
androidstringapp-inventoris-empty

Appinventor test empty string


What is the best way to test if string is empty?

I know it is possible to use if/else condition but is there possibility to use while loop?

I used both variants but in my case (see on picture) the while loop do not work and still get the empty string error. And is there some more elegant way to evaluate more fields in one while loop?

Screenshot


Solution

  • What is the best way to test if string is empty?

    use the is empty block

    but is there possibility to use while loop?

    to use a while loop to do some data validation does not make sense, because as you already found out, a while loop will block your device and will result in a runtime error. See also The model of event processing in App Inventor by Lyn

    is there some more elegant way to evaluate more fields in one while loop?

    instead of using a while loop, use an if - then - elseif - elseif - ... - else statement, see also the documentation

    enter image description here