Stevie H

unread,
Mar 10, 2015, 12:01:57 PM3/10/15
to mitappinv...@googlegroups.com
Just a quick question.
I would like to create a Top 10 leaderboard for my App but I don't really want to fetch the information from a web based database.
Is it possible to create a leaderboard within the App itself that will still be there when the user opens the App?
If it is possible, is there any tutorials or an example I could learn from? I have searched and searched the web for something but all tutorials seem to point to TinyDB which I thought was web based.
Any help would be appreciated.
All I need is the user to input there name and the score and name would be written into a list that would hold those values when the App is closed and then opened the next time.
 
Cheers
Steve

SteveJG

unread,
Mar 10, 2015, 12:09:37 PM3/10/15
to mitappinv...@googlegroups.com
TinyDB is entirely within the app and the device.   TinyWebDB is on the Web. 

How to use the TinyDB is here:TinyDB




This is your lucky day.

Regards,
Steve






Abraham Getzler

unread,
Mar 12, 2015, 6:07:49 PM3/12/15
to mitappinv...@googlegroups.com
There is only one TinyDB in your app.
It is a filing cabinet that stores multiple tag/value pairs.
It is accessible across screens.

Stop asking for multiple TinyDBs.

It makes it look like you have not done your required reading.

ABG

SteveJG

unread,
Mar 13, 2015, 7:24:31 AM3/13/15
to mitappinv...@googlegroups.com
@ Steve .... the way to learn to program is to program.  If you want help because you do not have the experience or the knowledge, it is usually prudent to be polite. Forum members are usually very glad to share their knowledge.

What have you tried?     None of us are mind readers, only you know what is required in your leader board, so it is perhaps best to try some things.

You discarded several suggestions that provide a framework for what users think you want to do but it appears you do not realize that.  The clever pieces of that code were written by ABG.    

If users have difficulty being polite, they can read the Inventor's Manual here http://www.appinventor.org/book2  and figure things like a special leader board out.   You got a piece of information that novice AI2 developers have difficulty with and are offended?  The  link might help you and others learn to program with AI2 blocks.  All the tools to solve your problem the way you want it solved are at the link.  An added bonus is you do not have to interact with the developers here who give their time and advice freely so others can succeed.

Incidentally, my best guess is that you are going to need AGB's example, some Lists and a TinyDB .. so you can retrieve the information saved when the app restarts and requires it.

Good luck,

Regards,
Steve

Stevie H

unread,
Mar 13, 2015, 8:52:16 AM3/13/15
to mitappinv...@googlegroups.com
Sorry If I offended anyone.
I do require help and I cannot find what I am looking for. Hence the reason for asking for help.
I just felt that there was a hint of sarcasm in the response that I received.

I am self taught in most things that I do from web design to VB for Excel sheets, so most of the time if I get stuck or hit a brick wall, I look at forums like these for guidance.

I am new to App Inventor and I have read and looked at a lot of tutorials to try and achieve what I would like to do but to no avail.
I have never used TinyDB before so reading that response was a shock.
We all have to start off somewhere, we were all beginners once.

My post back to your original links states what I would like to try and build so the structure was there prior to ABG post.

If you still feel that you can help I would appreciate it very much.

Steve

SteveJG

unread,
Mar 13, 2015, 10:03:51 AM3/13/15
to mitappinv...@googlegroups.com
To the best of my knowledge, no one has built a leader board quite like what you want; so you are going to have figure out how to do it; try some block and if something does not work, post what you tried with an explanation of what the code is supposed to do.

You do need to read the Inventor's Manual... with your background, it should be fairly understandable and will only take an hour.  I programmed Windows from C to C++ to VB and Pascal.  Many of the AI2 structures are/were foreign to me. (some still are :)  ).

Lists are arrays on a diet, the TinyDB is not sql, simple, storing every thing in Tags ...which are similar to Records. There is only one TinyDB in a project, however there needs to be TinyDB control on each screen you need the data.     Name a tag on one screen, it is accessible on another.  Frustrating is that "global" variables are not really global...if you need to use a variable on each screen you will have to initialize it on each screen ...the AI2 screens are really mini separate apps for practical purposes that can communicate with one another in a very klunky way.  This stuff is easy in VB, not in AI2 until you get the hang of it.

Here is some more reading AND experimenting stuff you can play with:

These are the closest to a tutorial that I am aware:


FIle and csv's .... another possibility for storing and retrieving you leader board info....here are links to a lot of stuff about them 




There are a few more.  

I would tackle the project this way:  1) write a small project to create the leader board     2) code a second project to learn to work with either TinyDB or File control and csv to save/retrieve data.   3) Put 1 and 2 together and link to your game.    Be aware, passing data between screens gets very complicated if you have lots of screens.

Try some blocks, capture a screen image of what you tried if things do not work as anticipated and post the image (jpg, png) here and someone will give advice.

Regards,
Steve



Stevie H

unread,
Mar 16, 2015, 6:23:49 PM3/16/15
to mitappinv...@googlegroups.com
I am almost there with building a TinyDB and retrieving the information into a top 10 leader board!
I would like help with one question and a link if possible please.

Is it possible to sort a TinyDB into descending order on one of the fields.
My TinyDB is Score, Name, Subject
As the DB is generated by a list of scores I would like it to be able to sort on the Score part in a descending manner. This would make my life a lot easier if it can do this.
I looked at the Bubble method but wasn't sure whether that would work with a TinyDB.

Cheers

Steve

Taifun

unread,
Mar 16, 2015, 6:47:51 PM3/16/15
to mitappinv...@googlegroups.com
let me recommend you to store your data in a list of lists and the complete list of lists in one tag in TinyDB
instead of sorting the data, I would add a new score at the correct position in the list instead, because that's easier

Taifun

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

Stevie H

unread,
Mar 17, 2015, 4:17:09 AM3/17/15
to mitappinv...@googlegroups.com
Isn't the problem with using a list, is that it is just a list that contains effectively 1 field? My DB contains 3 fields. Name, Subject and Score.
All examples I see for lists are just 1 field not multiple.

It is the score I need to sort and the Name and Subject will then be listed by the score being sorted from the relevant index.

Ideally, I would like to pull the results in from whatever system I use into a a different screen, but I would settle for a leader board being part of a screen reading from a file or DB. The issue there is that you can only have 1 TinyDB in the App.
So unless I could say SELECT TOP10 Scores from DB Where subject = "Addition" that would work.

I haven't checked out Fusion Tables yet as they seem to have field headers. I will start reading up on that. I don't think TinyDB is going to help as it is effectively a list but with 3 parameters (indexes) which it looks like you cannot sort on.

Thanks

Steve

Taifun

unread,
Mar 17, 2015, 10:27:19 AM3/17/15
to mitappinv...@googlegroups.com
Isn't the problem with using a list, is that it is just a list that contains effectively 1 field? 
each item of a list of lists is again a list

btw. the example of ABG does exactly what you need https://groups.google.com/d/msg/mitappinventortest/_SNEp0JhBo4/wqo9f5EjJzoJ

Taifun

Stevie H

unread,
Mar 10, 2015, 12:40:26 PM3/10/15
to mitappinv...@googlegroups.com
Thank you. I will check those out.
I have 4 different areas where I will want a top score. Can I pull in 4 different TinyDBs or will I have to pull in from 1 and have an identifier to say which screen it came from?
 
Steve

Stevie H

unread,
Mar 12, 2015, 2:16:48 PM3/12/15
to mitappinv...@googlegroups.com
SteveJG

Thanks for those examples but they aren't really what I wanted to do and not being an expert in AI2 would it be possible to point me in the right direction please?
I have an app that has 4 separate screens with a 60 sec timer that spits out random maths sums. At the end of the 60 secs there is a final score.
Ideally I would like a TinyDb for each subject, Addition, Subtraction, Multiplication and Division but if I can only have 1 TinyDb per App then I will put an identifier in the Db that says which subject it came from.
Again, ideally a top 10 highest scores is what I would like.
So if the score is greater than the bottom score, (index 10 I suppose), then put it into the table where it should sit.
I would then have a button on the main screen that pointed to a screen called TopScores and then the list reading from the TinyDb would populate the 10 positions.
The info in the TinyDb, if I can't have 4 different ones, would be PlayerName, Score and Subject. If each subject can have it's own TinyDb then I would only need PalyerName and Score.

Unfortunately looking at those examples doesn't really give me a starting point.

Please help!

Thank you in anticipation.

Steve

Stevie H

unread,
Mar 13, 2015, 5:16:59 AM3/13/15
to mitappinv...@googlegroups.com
Thanks Abraham. If I wanted a sarcastic response I would have spoken to my wife!!
I actually posted and then read more information about TinyDbs prior to your posting and realise that I can only use 1.

As a novice to AI2 I am looking for some help as I cannot find anything on the internet about how I want to set up my leader board.

Responses like yours do this group no favors so please be a little more considerate!
If you can't provide anything constructive please don't respond.

Is there anyone else out there that cn supply a link to get me started with a Top 10 Leader Board?

Steve
Reply all
Reply to author
Forward
0 new messages