Skip to first unread message

Mark Barr

unread,
Feb 8, 2014, 7:12:01 AM2/8/14
to mitappinv...@googlegroups.com
Guys

Im having problem with if the
The attached image shows the blocks for the screen
the screen has 4 buttons
depending what the contents of label2 is determines whether the button is visible or not

The problem is it always sets the visibilty to the last if then statement even if label2 = the requirement of the first ifthen staement

any ideas
Mark






fturbak

unread,
Feb 8, 2014, 7:40:24 AM2/8/14
to mitappinv...@googlegroups.com
Hi, Mark --

The problem is the blocks for your tests in the if statements.  For example, the test

calculates a boolean (true/false value) for "compare texts", and uses that boolean value as the tag in TinyDB1. Presumably you didn't store anything at a "true" or "false" tag, so TinyDB1.Get value returns the empty string. It turns out in App Inventor that any value that is not false is treated as true in the context if an "if" statement, so both of your "if" blocks execute their "then" parts. 

To fix this problem, you need to rearrange the above blocks to return a boolean, as follows: 

In the rearranged version, TinyDB1.GetValue looks up the desired tag, and returns a string that's compared to the text in Label2. The result of this comparison is now the desired boolean to be used in the "if" block. 

Best wishes for your project, 

- lyn -

Mark Barr

unread,
Feb 8, 2014, 8:32:59 AM2/8/14
to mitappinv...@googlegroups.com
Thanks lyn

The following works

Mark

 

Taifun

unread,
Feb 8, 2014, 9:18:08 AM2/8/14
to mitappinv...@googlegroups.com
if you see yourself writing the same blocks again and again, then there is a possibility of some simplification, see screenshot

Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

Reply all
Reply to author
Forward
0 new messages