Skip to first unread message

Wai Hung BAC

unread,
Apr 16, 2019, 4:45:09 AM4/16/19
to MIT App Inventor Forum
Hi all AI2 Masters,

 I 'm creating an app made up of 3 screens. Thanks both Chris and ABG for their valuable advice in my previous post regarding this app.
 
I have amended my blocks a bit. 
But I found that upon adding new data in "update screen" the input data set cannot be searched from the "search screen". Does it mean that the new data set cannot  store in the tinydb created?   What is the problem with my blocks? How can I do so ?

Also, when I have selected the location, date and with weight input in the "update screen" these values cannot be shown immediately in the label boxes. 
Any tricks to achieve this?

Meanwhile, there are some opinions that it is preferable to put all blocks of different functions on the same screen. Whilst one subroutine is executing, the others are set  invisible.  Do I need to change to such design ? If it is so, how can I do  it? (by dividing single screen using horizontal arrangement and putting blocks of one subroutine into individual area?)

Thanks a bunch!

Bac
blocks_main_menu_screen.png
blocks_search_Screen.png
blocks_update_screen.png

TimAI2

unread,
Apr 16, 2019, 5:44:11 AM4/16/19
to MIT App Inventor Forum
HOWTO: Transfer data between screens using TinyDB Demo.


Use different screens wisely

If you decided to use different screens, then you should switch them correctly, else you will run out of memory after a while...      
The recommended method of switching screens in App Inventor
(Thanks Taifun)

Also see demo: multiscreen.aia

If you haven't done it already....

Chris Ward

unread,
Apr 16, 2019, 6:28:01 AM4/16/19
to MIT App Inventor Forum
Hi Wai

It is very simple - you just have to drag an instance of the TinyDB component onto every screen that needs to use it.
You will have three Screens and three instances of the same TinyDB :)
Their namespace (see the Component Properties Pallet) should be identical for all three instances. Default is TinyDB1, which is just fine.


ABG

unread,
Apr 16, 2019, 1:38:30 PM4/16/19
to MIT App Inventor Forum
Can you post a copy of Booklist.csv here?

It's impossible to see if your app is correct without it.

If necessary, obfuscate the contents to protect secrets.

ABG

Wai Hung BAC

unread,
Apr 17, 2019, 5:20:45 AM4/17/19
to MIT App Inventor Forum
Hi ABG, Chris,

I captured the screen of booklist.csv opened in notepad as attached.
I also enclose designer screens and working screens of both search and update modes.
I tried running the project again and encountered an error as shown in screenshot_pf_add_update_error_190416.
Could you help spot out what gone wrong?

Thanks a lot.
Bac
screenshot_pf_add_booklist-csv_190402.jpg
screenshot_pf_add_update_error_190416.jpg
screenshot_pf_add_search_s_designer_190402.jpg
Screenshot_search_s_working0416.png
screenshot_pf_add_update_s_designer_190402.jpg
Screenshot_update_s_0416.png

ABG

unread,
Apr 17, 2019, 10:31:14 AM4/17/19
to MIT App Inventor Forum
Judging from the error message contents, it looks like you mis-counted 
column numbers going in or out of TinyDB.

I'm not a big fan of storing items in lists of lists, if there's
a chance of empty slots throwing the column counts off kilter.

I prefer to get very granular for my data updates if doing
small data volumes locally, like in
where I build up the tinyDB tags with text JOINs, or
use separate TinyDB NameSpaces for table columns, like in
this Fruit Stand sample

ABG

ABG

unread,
Apr 17, 2019, 10:34:53 AM4/17/19
to MIT App Inventor Forum
Could you export an .aia file of your project 
(hopefully English)
and post it here for us to play with?

I would like to have a sample table-driven update app
to use as an example.

ABg

ABG

unread,
Apr 17, 2019, 10:52:20 AM4/17/19
to MIT App Inventor Forum
I notice from your sample data that there are no duplicate
rows for the same scan code, meaning that the scan code is
unique among items being scanned.

So the app is not like a city lending library ,
where the same book ISBN number might exist in multiple
copies at different locations.

Am I right?

(If I am wrong, I see trouble coming.)

ABG

Wai Hung BAC

unread,
Apr 25, 2019, 6:15:19 AM4/25/19
to MIT App Inventor Forum
Thanks ABG.

You are right. Each item has unique scan code.
But its location, quantity and expiry date may change during each update.
I intend to replace the above 3 fields with the input data and save into the tinydb. Then the tinydb could be downloaded into spreadsheet anytime to get the most updated data.  

It seems that the loop count has exceeded the length of list but I get lost of what gone wrong.

Hope you can help.
Many thanks! 


PF_Add.aia
Booklist.csv

ABG

unread,
Apr 25, 2019, 9:39:21 AM4/25/19
to MIT App Inventor Forum
Your input csv file has only 4 columns, but
you try to add a 5th (date) column using a replace operation
in the btn_save_data Click event.

You have a choice of two different ways to approach this ...

  1. Add a 5th column to your data file, with today's date as default, or
  2. in your save procedure, repeatedly add items to each row before its replacements, until the row has 5 items to replace.
ABG
four columns.PNG
Booklist.csv
btn_save_data.PNG

Wai Hung BAC

unread,
Apr 27, 2019, 4:22:21 AM4/27/19
to MIT App Inventor Forum
Thanks ABG for your great advice.
Let me fix the fault and trial again.

Thanks a lot!
Bac

Wai Hung BAC

unread,
Apr 27, 2019, 4:41:04 AM4/27/19
to MIT App Inventor Forum
Hi ABG,

I revised the csv file to have 5 columns but the same error occurs. Is this normal?
Thanks a lot!
Bac
Booklist.csv

ABG

unread,
Apr 27, 2019, 3:26:06 PM4/27/19
to MIT App Inventor Forum
Before I take the time to open your .aia,

Did you empty out TinyDB so you don't trip over
leftover short rows?

ABG

Wai Hung BAC

unread,
Apr 28, 2019, 7:04:54 PM4/28/19
to MIT App Inventor Forum
Hi ABG,
You mean adding a subroutine to clear the content inside tinydb at the start of the program?
Let me try going through the blocks and return to you.
Thanks a lot
Bac

ABG

unread,
Apr 29, 2019, 10:34:45 AM4/29/19
to MIT App Inventor Forum
You mean adding a subroutine to clear the content inside tinydb at the start of the program?

Not if your program needs to keep data between runs.

I meant a one shot cleaning using the Blocks Editor Do It
 facility on a loose Empty TinyDB block.

It's like washing the pot before cooking in it.
Don't wash the pot while cooking.

ABG

Reply all
Reply to author
Forward
0 new messages