Re: Multiple attempts in Retrieving Data with TinyWebDB

154 views
Skip to first unread message

layolayo

unread,
Dec 30, 2011, 10:46:26 PM12/30/11
to tAIR - the App Inventor Repository
Good day to all - just joined this group coming from AICoffeeShop,
thanks for the invitation (Tony and Gary).

My query is around the TWDB and iterated calls not doing what I was
expecting. A bit of a cut and paste from AICS follows:

I'ev been using AppInventor for a few days now gone through a few
tutorials and have started developing my own. But am coming up against
a problem which is pretty frustrating and I am sure there is a simple
answer to it. My current TinyWebDB set-up is designed for text fields
in the AppEngine. I am using 1 master list/tag which stores a list of
names, then each name has it's own tag and series of values.

One program I have enters data into this configuration and works
fine.

The user program is set to access the TinyWebDB and download the
latest data (bulk download) on request and store data in the TinyDB.

The problem I am coming up against is while running through each value
in the master list and individually making a call to TinyWebDB for
each value.

I have tried [For Each] unsuccessfully, another config uses a [For
Range] loop based on a copy of the master list, then choosing each
value in the master list from the index (loop value) making a call to
TinyWebDB - and in that GotValue procedure I am deleting the value
from the list. Unfortunately only the last value in the Master List
gets read from TinyWebDB.

I have tried to set-up a check for [ while length of list > 0 ] run
the TinyWebDB retrieving procedure, but the system locks up? tried
including [for each] loops to hold the system up while waiting for the
got value response....

Any ideas? my TinyWebDB.GotValue event uses If controls checking tag
against what I am sending to TinyWebDB - It looks like the For Range
loop is running and the next call to TinyWebDB cancels the previous
one, therefore only leaving me with the last item in the master list
being downloaded.

https://picasaweb.google.com/layolayo/Shared?authuser=0&authkey=Gv1sRgCIGg5IH9sMjBCw&feat=directlink

I have managed to get this working with a button and a check on the
length of the copied main list. Then using the value from item at
index 1 - I make a call to twdb, and then delete the value at index 1
- the button is then updated with ( "x lists left to update" ) once
all lists are updated (i.e. copied list is empty) the user can
continue... a bit of a work around, but operational. This is fine when
I only have 3 or 4 items in the Main List. If this grows, and it
will ! It will become slightly annoying for the user.

Maybe the issue is with my logic, I am looking at this from the
following angle:

tag: Main List
values: Tea-a, Tea-b, Tea-c

tag: Tea-a
values: Darjeeling, 5/10, great with milk

tag: Tea-b
values: English Breakfast, 9/10, have with porridge

tag: Tea-c
values: Ceylon, 1/10, doesn't go with anything

In the admin screen - a new tea is added and then all the details are
filled in - the Main List then becomes the holder for the ListPicker.

A requirement is the functionality of using the indexes of the Tea-a,
Tea-b lists to control the UI.

First impressions would suggest (at least to me) that the original
blocks would handle this...

**>>Happy New Year <<**

Layolayo

Gary

unread,
Dec 31, 2011, 5:21:40 AM12/31/11
to theaire...@googlegroups.com
Layolayo 

I am sorta running way past overload

If you get nowhere

and nobody gets back here

say something in a few days

Gary

Taifun

unread,
Dec 31, 2011, 9:03:02 AM12/31/11
to theaire...@googlegroups.com
as Tony already suggested, I also would recommend using a list of lists and downloading the complete list of lists in one go
working with list of lists: https://sites.google.com/site/blocks123/lists
then in AI you could split the list of lists in two parts, a tag list and a value list (which is a list of lists)...
Taifun

Anthony Barnes

unread,
Dec 31, 2011, 9:13:38 AM12/31/11
to theaire...@googlegroups.com

Layo,
There is a list of list template in tair that use list pickers with multiple lists.
Code.google.com/p/the-ai-repository/downloads/list that may be a little help although it is not storing to a tiny db, it shows how to use a pickpocket to call sub lists.

You coulda use a picker for main and then according to what was chosen, load the sub list in another list picker. Then you wouldn't need to copy all those lists.

You can also put notifiers in the after picking event to add a new value our delete the selected value.

Hope this gives you some ideas.

Tony Barnes
Tair.info
Http://groups.google.com/group/theairepository

Gary

unread,
Dec 31, 2011, 9:44:32 AM12/31/11
to theaire...@googlegroups.com
and my JSON example gets the list of lists out of a twdb

Study the Web1.gotText block

This one is lists of lists from twdb.

I need to look at it and decide if it was written in English or something that resembles English on the surface and is actually me writing what was going on in my mind at the time :-P

CharacterTinyWebDB.GotValue is getting the index for the weapons for the character you picked
WeaponTinyWebDB.GotValue is getting the selected weapon for that character and tier.

Gary

layolayo

unread,
Dec 31, 2011, 11:31:47 PM12/31/11
to tAIR - the App Inventor Repository
HAPPY NEW YEAR HOPE 2012 BRINGS HEALTH & HAPPINESS TO YOU ALL
**********************************************************************************************

Just looked through

https://sites.google.com/site/blocks123/lists
and
http://sites.jsoft.com/rm/home/fb/fblptwdb

using List of Lists seems possible - I am just wondering how to best
manage the indexing. i.e. I will have no control over the length of
the Main List, and each item in the Main List will reference a List
within that list at a specific index (i.e. (Tea-a, Tea-b, Tea-c ,
(Darjeeling, Tea-a-2, Tea-a-3), (English Breakfast, Tea-b-2, Tea-b-3),
(Ceylon, Tea-c-2, Tea-c-3))

although - thinking out loud
(length of Main List / 2) = number of items in main list
extract items 1 to No. Items in main list to List-picker
Choose first item - sub-list index for first item = index + no items
in main list ( 1 + 3 ) = 4
second item - ( 2 + 3 ) = 5
third item - ( 3 + 3 ) = 6

But... if I have the about list of lists and I then add a new item to
the Main List (Tea-d)

best practice would be ??

Hope you all had a good night!

Layolayo

Gary

unread,
Dec 31, 2011, 11:47:36 PM12/31/11
to theaire...@googlegroups.com
Not quite sure what best practice you are asking about. If you get the number of items in a list when you get it, things should just work.

I plan on thinking about it the rest of the year :-)

Good luck.

Gary

layolayo

unread,
Jan 1, 2012, 2:15:28 AM1/1/12
to tAIR - the App Inventor Repository
Cheers Gary - so it is! I may be a little convoluted using these extra
variables, but it keeps my head straight... :)

Just in case anyone else is following and this helps:
I make a call to TWDB for the full-data
extract to two variables based on length of full-data
MainList - List of Tea
DataListofLists - Tea Data

if I add a new Tea - new items are added to both to keep indexing
correct
if I delete a tea - both items are deleted from the lists

ListPickerElements = MainList
When editing data for a Tea - I pass the sub list to DataHolderList
Make adjustments then Replace item in DataListofLists against the
SelectionIndex from ListPicker

On saving - I have a VarFullList which appends MainList and
DataListofLists

Phew - Thats the admin screen rewritten. Now just hoping I can save it
all and extract off AppInventor before it closes down.
Then at some point start on the user UI

Layolayo

Gary

unread,
Jan 1, 2012, 3:00:58 AM1/1/12
to theaire...@googlegroups.com
tea mmm

>I make a call to TWDB for the full-data 
what is full-data?

Do you have two apps, one to manage the data and one to display the data?

I think twdb is a fantastic tool. 
I am starting to think most of what we do can be done in fusion tables
  and may be a bit more useful.

The thing is, fusion tables are sorta spreadsheets that you can get at with SQL like commands.

Our well loved twdb could be a great place to put data that is not sqlish and it also lets us put server side behavior in it.

Hmmm

I am drinking coffee, I will switch to tea soon, My wife got me a flavored tea that is supposta be egg nog ish. mmm?

Gary

layolayo

unread,
Jan 1, 2012, 6:56:57 AM1/1/12
to tAIR - the App Inventor Repository
Okay - so I got this whole thing working just fine!

full-data = (Tea-a, Tea-b, Tea-c, (Darjeeling, Tea-a-2, Tea-a-3),
(English Breakfast, Tea-b-2, Tea-b-3), (Ceylon, Tea-c-2, Tea-c-3))
Main List = (Tea-a, Tea-b, Tea-c)
DataListofLists = ((Darjeeling, Tea-a-2, Tea-a-3), (English Breakfast,
Tea-b-2, Tea-b-3), (Ceylon, Tea-c-2, Tea-c-3))

HOWEVER - There is a failure, a major failure, which maybe I should of
seen coming - each of the sublists holds approx 88 values and when
attempting to save, nothing occurs. What is the Max List/No Values
Size?

Correct - I am using two apps 1)administrator app for entering the
data and 2) user app for looking at data and making their own
adjustments

Just doing a search on Fusion Tables as I am not aware of these...
NICE!! this would be perfect - do you have any info on accessing this
as the API via AI?

Coffee in the Morning and Tea during the Day and Beer/Wine during the
Evening [Perfect]

Layolayo

On Jan 1, 6:00 am, Gary <gary.freder...@jsoft.com> wrote:
> tea mmm
>
> >I make a call to TWDB for the full-data
>
> what is *full-data*?

layolayo

unread,
Jan 1, 2012, 8:06:52 AM1/1/12
to tAIR - the App Inventor Repository
Got access to my personal FusionTables and extraction looks pretty
straight forward.

Do you know if it is possible to access a shared fusiontable - example
table link: http://www.google.com/fusiontables/DataSource?snapid=S35000155uJ

not sure if this would be possible as an app - unless it was running
on the appengine, so bandwidth could be analysed and charged for...?

Gary

unread,
Jan 1, 2012, 10:54:11 AM1/1/12
to theaire...@googlegroups.com
You can share with the world
or add accounts that can share

Check out what tair and the other user contributed sites have.


Gary

Taifun

unread,
Jan 1, 2012, 11:38:58 AM1/1/12
to theaire...@googlegroups.com
in your first post you said:
tag: Main List
values: Tea-a, Tea-b, Tea-c
tag: Tea-a
values: Darjeeling, 5/10, great with milk
tag: Tea-b
values: English Breakfast, 9/10, have with porridge
tag: Tea-c
values: Ceylon, 1/10, doesn't go with anything

in your last post you said:
full-data = (Tea-a, Tea-b, Tea-c, (Darjeeling, Tea-a-2, Tea-a-3),
(English Breakfast, Tea-b-2, Tea-b-3), (Ceylon, Tea-c-2, Tea-c-3))
Main List = (Tea-a, Tea-b, Tea-c)
DataListofLists = ((Darjeeling, Tea-a-2, Tea-a-3), (English Breakfast,
Tea-b-2, Tea-b-3), (Ceylon, Tea-c-2, Tea-c-3))

-> this is in my opinion a little bit strange definition...
so my suggestion is to define the lists like that (according to your first post):
full list = ( Tea-a, (Darjeeling, 5/10, great with milk))
               Tea-b, (English Breakfast, 9/10, have with porridge)
               Tea-c, (Ceylon, 1/10, doesn't go with anything)
             )
in AI you split the full list into a tag list and a value list like that:
tag list = (Tea-a, Tea-b, Tea-c)
value list = ((Darjeeling, 5/10, great with milk)
                  (English Breakfast, 9/10, have with porridge)
                  (Ceylon, 1/10, doesn't go with anything)
                 )

...but probably I did not understand what you like to do, I'm not a tea expert... :-)

Taifun

layolayo

unread,
Jan 1, 2012, 10:22:21 PM1/1/12
to tAIR - the App Inventor Repository
Hi Taifun thanks - just a bit of history in there after the first post
of using multiple tags, I moved on after help from Gary and Co. to a
single list of lists in which I extracted the data in that full-list
format, (your structuring would work easier in adding new items(tea in
this case)), however I did come across another issue in having a
single tag holding too much data.

So it is back to the drawing board - Fusion Tables looks to be the way
to go.

All the best

Layolayo

layolayo

unread,
Jan 1, 2012, 10:24:28 PM1/1/12
to tAIR - the App Inventor Repository
OK - so if you use the id:2531362 you would have full access to the
table? I was trying to use id:S35000155uJ from the link!!!!

... now I need to locate another AppInventor Server - can you
recommend please? ...

Thanks in advance

Layolayo

Gary

unread,
Jan 2, 2012, 8:30:35 AM1/2/12
to theaire...@googlegroups.com

On Sunday, January 1, 2012 9:24:28 PM UTC-6, layolayo wrote:
OK - so if you use the id:2531362 you would have full access to the
table? I was trying to use id:S35000155uJ  from the link!!!!

I tried both id's and did not get a table.

I just had a cup of Bigelo Eggnogg'n tea.

Here are the mostly empty fusion tables I am using to play with Skyrim


If an item in the cooking table is a kind of recipe, it's ingredients are keys to get the items that are kind of ingredient

alchemy is similar, the Name of a recipe can be used to look up an ingredient with that effect

I will add the materials to smith and upgrade weapons next.

I am using Google docs, I put the info into a spreadsheet, create a fusion table from a sheet in the spreadsheet and get the id from the docid.


... now I need to locate another AppInventor Server - can you
recommend please? ...

I have not tested the personal server with fusion tables. It would be interesting to know if it works.


I will probably have a cup of chamomile next.

Gary
 

Thanks in advance

Layolayo
Reply all
Reply to author
Forward
0 new messages