2016년 11월 29일 화요일

Saving Checkmarks and data I input as a user, not through program


I am trying to save my check marks so when I uncheck them, and go to another screen, they remain unchecked.. Also I cannot figure out how to get my text to remain saved after inputting it in a text box, it just goes away...

-- 
Look for AI2 TinyDB tutorials.
refer to: https://www.youtube.com/watch?v=mKe5a8F6uvY

-- 
I tried doing it with TinyTB but it only saves it then restores it somewhere else... And doesn't work for the check marks..

-- 
To save a checkbox, save true or false under the tag equaling the checkbox text or meaning.

So if you were filling out a form for user ABG and you had check boxes "old", "young", "sweet", "cranky",
you might save them in TinyDB as tag/values like
"ABG-age"/"old",
"ABG-temper"/"cranky".

-- 
Another way you might encode your check boxes in TinyDB might be as a list of pairs, using for example my previous post...

tag: "ABG"
value:  a list of pairs:
(
("age"  "old")
("temper" "cranky")
)

This is a good organization for use with the lookup in pairs list block.

The secret to using TinyDB is to regard it as a refrigerator in a hot climate.
Put your data away in TinyB without delay, and get it out just before you use it.

-- 

This is how I got it to restore my checks after they are unchecked (I enabled and checked them in the designer screen), I cannot figure out how to get it to save my checks after I uncheck them and exit the app or leave to another screen.... I tried doing everything you said with no success, I tried typing the text with the check mark, I tried separating the check by adding text box (which is what I would like to to do because I want to b e able to add and save my text in a text box) and nothing I do makes the checks or text stay....

-- 
I have an example project for you to look at and see if you can understand what is going on to save checkbox states between screens.
I believe that you want to be able to tick the checkboxes in screen1, then open screen2 and see the checkboxes in the same state as they were in screen1.
This example project does that by saving the initial state of the checkboxes in screen1 or if they are changed in a TinyDB database.
When screen2 is opened, the checkboxes there are set to the saved states of their counterparts in screen1.
If they are changed in screen2 their new states are saved in the database also.
So when returning to screen1, the checkboxes in screen1 will be changed to reflect the new states.
Study the project, read the comment bubbles and ask here if you have further questions.

Blocks for Screen1:
 screen1.png

Blocks for Screen2:
 screen2.png

-- 
Each Screen is different and worded differently but Screen 1 is exactly what I needed! Thank You! Would you happen to know if this would work for saving text entered into text boxes?? I think not but thought because not the same concept but thought I would ask in case you know how to save the text into other text box's that is entered by the app user...

-- 
Yes you can save the text entered in exactly the same way.
When you want to save the text use StoreValue.
To restore the textbox text from the saved tag for that textbox use GetValue.

-- 
Ok, it work for the first two screens but I cannot get it to do any more screens... I am so thankful for the help..

-- 
It should work the same for other screens.
Maybe show the blocks for a screen that is not working.

-- 


Got it to work, I left out words on the text block, fixed it and got it to work, I figured out the text too, I used the "lost focus" for "changed" and adding what I need to the previous blocks, success! Thank you, Now I'm working on making it so we can add text or pick from a list, This is the best! Thanks again!

-- 
Trying to get my list picker to let me use more than one text box. I have 40 text boxes but the book I have only shows me how to select 1 item from my list.


-- 
If your 40 text boxes represent 40 of the same type of thing, you are doing multi-select.
See this app in the gallery and its doc for how to do multi-select...

If you are filling in a 40-item form, instead consider keeping the target text box components in a list,
and using the Any text Box blocks in a procedure .

-- 
Got it, I have to pick my selection then pick the box I want it to go into, Thank You!










-- 
I see from your blocks you have a TinyDB named TinyDB3.

I hope you don't also have other TinyDBs 1,2,...
They all point to the same data store.

-- 
I do because after 40 checks it didn't want to store anymore for some reason... SO it can store everything?? I figured it could but It just didnt want to

-- 
From the Designer help on TinyDB:

TinyDB is a non-visible component that stores data for an app.
Apps created with App Inventor are initialized each time they run: If an app sets the value of a variable and the user then quits the app, the value of that variable will not be remembered the next time the app is run. In contrast, TinyDB is a persistent data store for the app, that is, the data stored there will be available each time the app is run. An example might be a game that saves the high score and retrieves it each time the game is played.
Data items are strings stored under tags . To store a data item, you specify the tag it should be stored under. Subsequently, you can retrieve the data that was stored under a given tag.
There is only one data store per app. Even if you have multiple TinyDB components, they will use the same data store. To get the effect of separate stores, use different keys. Also each app has its own data store. You cannot use TinyDB to pass data between two different apps on the phone, although you can use TinyDb to shares data between the different screens of a multi-screen app.
When you are developing apps using the AI Companion, all the apps using that companion will share the same TinyDb. That sharing will disappear once the apps are packaged. But, during development, you should be careful to clear the TinyDb each time you start working on a new app.
-- 

댓글 없음:

댓글 쓰기