Skip to first unread message

mounib Mekhilef

unread,
Jan 14, 2017, 6:08:33 AM1/14/17
to MIT App Inventor Forum

Hi there,

Likely this is the right place to put my question.
Actually I need to do some debugging therefore need to access to some variables contents without distroying my layout on the app interface.
Thinking to use a new screen, where to display in textbox (es) the values I'm interested in.
However this seems impossible. My second screen don't have access to anything.
Would some have an idea to solve that?

Many thanks in advance.
M

Taifun

unread,
Jan 14, 2017, 9:58:36 AM1/14/17
to MIT App Inventor Forum

  1. Use different screens wisely
    Before starting to create another screen, first you should think about is it really necessary? See also Building apps with many screens and SteveJG's post about advantages/disadvantagesbecause in only one screen you also can use vertical arrangements to simulate different screens, just set the arrangements to visible = true/false as needed... See also Martyn_HK's example about how to use Tabs in App Inventor and another example from Cyd
          
    The recommended method of switching screens in App Inventor


A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the
 Top 5 Tips: How to learn  App Inventor

You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.

Taifun

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



Ghica

unread,
Jan 14, 2017, 10:03:17 AM1/14/17
to MIT App Inventor Forum
Two possibilities:
First and above all, use DoIt. In the blocks editor, klink with your right mouse button on the variable you would like to know the value of, and choose DoIt. http://ai2.appinventor.mit.edu/reference/other/testing.html
The other way is to have a label on your screen, where you display the values you are interested in. When you are done debugging, you make the label invisible and it will not take any space anymore.
Cheers, Ghica.

mounib Mekhilef

unread,
Jan 14, 2017, 11:27:01 AM1/14/17
to MIT App Inventor Forum
Hi Taifun,
Thx for the links that I didn’t discover by my own. I’ll try that quickly.
As you might easily guess, I’m not asking before studying and guessing/checking. Sometimes it’s not obvious and this is the benefit of experience sharing … sometimes  much more efficient when you don’t get the concept.


Thanks a lot again.

M

mounib Mekhilef

unread,
Jan 14, 2017, 11:27:32 AM1/14/17
to MIT App Inventor Forum
Hi Ghia

Thanks for the suggestions.
I wanted to avoid this option as I have several variables to observe. Will try also the solution from Taifun and see how it’ll go.

Thx again.

Ghica

unread,
Jan 14, 2017, 11:56:00 AM1/14/17
to MIT App Inventor Forum
Passing variables from one screen to another:
Use TinyDB or use open another screen with start value.

http://www.appinventor.org/content/howDoYou/screens/share
http://stackoverflow.com/questions/27872652/how-to-pass-data-between-screens-using-intent-in-mit-app-inventor
Cheers, Ghica

Ghica

unread,
Jan 15, 2017, 6:00:55 AM1/15/17
to MIT App Inventor Forum
Hi Mounib,
You wrote to me privately, please don't
<<
Do you mean that it’s the only way to capture some internal variables values while debugging or is there any good practice to do so.
remember the idea is to track the variables not to build something.
Naively I would say, Is there a way to call external functions (in whatever language) to process some local computations ?
<<

The best practice of developing App Inventor apps is to experiment and to develop incrementally. Use the AI companion on a real phone if possible.
Too often I see some very large projects with umpteen screens, no procedures and thousands of blocks, in a forrum post with title "help!, it does not work, why?". Well, I do not know and I do not want to find out..

The debugging facilities in App Inventor are, in order of my preference:
1. DoIt. Can easily be used to see what values of global variables are and what results of procedure calls are.
2. Debug labels. You can see what happens on your screen, useful if things change releatively fast. It is easy to get rid of them by making them invisible (or finally, when your project is ready, just delete them).
3. Notifiers. Error messages in a notifier is always a good idea. You can also use notifier warnings to display what is happening in your app. You can get rid of them by disabling or deleting the block quite easily.
4. Really a last resort (so far I never neeeded it), when things go very wrong, is to use logcat.

Calling external functions, apart from making procedures within App Inventor is not possible. You would have to write an extension to do that, but that does not seem a good idea just for the purpose of debugging something.
Cheers, Ghica.

mounib Mekhilef

unread,
Jan 15, 2017, 6:06:57 AM1/15/17
to MIT App Inventor Forum
Hi Ghica,

Sorry for the private answer it wasn't intended. Apparently Google Groups don't allow posting by answering emails...

Re the ideas you put, I'll check the 1st and 4th options as I wasn't satisfied with 2 & 3 (they were my natural salutions). 
I'll put the post as completed as soon as I get my own assessment.
Thanks so much for your help.
Reply all
Reply to author
Forward
0 new messages