Hello everyone,
even though I have put about 21 controls into a procedure; does it only check the first one?
Greetings
Nicola
See the documentation MIT App Inventor Control Blocks
Tests a given condition. If the result is true, performs the actions in the -then sequence of blocks; otherwise tests the statement in the -else if section. If the result is true, performs the actions in the -then sequence of blocks; otherwise, performs the actions in the -else sequence of blocks.
Taifun
Ciao Nicola, la tua sequenza di else if è l'equivalente di uno switch-case-break del "C". In pratica appena trova una condizione soddisfatta, tutte le successive non le esegue più.
Per cui se la prima è soddisfatta, ciao ciao alle altre
Se vuoi che vengano controllate tutte le condizioni togli gli else if e usa solo degli if.
Ciao, Ugo.
You have two other errors to deal with:
You call the procedure to mark the zeroes red immediately after entering Screen1.Initialize, before the rest of the app has a chance to change the values in those text boxes (Labels) from TinyDB. That procedure call should be moved AFTER all those TinyDB GetValue calls.
Those GetValue calls use a default of empty text if nothing is found, but they are retrieving a blank for the first run. Those blanks will poison all the numeric comparisons to 0 in your procedure. It would have been better to use numeric 0 (blue) as those defaults.
Ciao Nicola, ma allora qual è l'errore ?
Ovvero che cosa ti aspetti dalla sequenza di if ?
Ho notato che il valueiftagnotthere è una stringa vuota, mentre gli if lavorano sul numero 0. Non credo che gli if posssano funzionare in questo modo.
Prova a mettere il valueiftagnotthere = 0 e vedi se cambia qualcosa.
EDIT I've seen that @ABG has anticipated me about the same doubt (empty string vs number 0)...
Ottimo; Nicola !!!
Ho visto che hai risolto: era il problema dello "0 mancante" o del GetValue troppo presto ? (così imparo anch'io
)
Ciao e buona serata...
Ugo
Ciao Ugo,
il problema derivava dal fatto che come affermava giustamente @ABG; la chiamata di procedura doveva essere spostata alla fine di tutte quelle chiamate TinyDB GetValue e non all'inizio.
Grazie del feedback Nicola!!
A questo punto non mi rimane che augurarti un ottimo Natale ed un anno nuovo pieno di ...app funzionanti ...
Ciao, ugo.
Grazie Ugo,
tantissimi auguri di Buon Natale e felice Anno Nuovo anche a te e a tutto lo staff di Mit App Inventor
Saluti
Nicola
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.