2014년 12월 23일 화요일

Global Variables & Separate Screens


I used to program with App Inventor until school started. I'm in college and had to set it aside for a bit.

It's break now and it ends the second week into January, and I'm dying to make a (fairly complicated) calculator release.

Basically, I want to have different screens set up for different reasons. So ScreenA calculates what ScreenB and ScreenC has the stored value as. All the variables are global, but I can't see other screen global variables from ScreenA.

I'm kind of at a stand still for my project. How can I work with this?

--
Each App Inventor screen behaves like a separate app.  Because of this variables use on one screen can not be used on another screen unless the information is 'passed' from one to the other.  The simple way to do this is to store the variables that are going to be used on different screens using a TinyDB.  A TinyDb has to be placed on each screen that will use the variables and stored under a tag.  The TinyDB can retrieve what is on another screen by using the tag it was stored under.

Here is some great holiday reading...and it is free...the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.

You could  search in the forum using the Search for topics box to the right of the colorful google at the top of this page like changing screens and passing variables between screens    or calculator      to find many forum discussions of the topics that you expressed an interest in.

--
Alternatively you could have the layouts represent screens. One of the properties for a layout is visible. When you click a button for example, you can set visible to false and the "next screen" layout to true. It requires more control and tacking but it gives you the advantage of holding the variables that you need on just one screen (and the blocks as well) rather than having multiple and building the blocks for them.

http://ai2.appinventor.mit.edu/reference/components/layout.html

--

댓글 없음:

댓글 쓰기