How to use Variables to Add Total Numbers from Different Sessions in a day?

Hello.
I am working on a Pedometer app that records:

  1. The steps of the user in a session.
  2. The distance covered in a session.
  3. The calories burnt in the session.

The above scenario takes place in the Home Screen after the user logs in through Google.

What I want now is -
After “Stop” is pressed, the values of the session to be stored somewhere and show in the Profile (Vertical Arrangement) on the same screen.
And for 24 hours, the addition of the values of all the sessions’ of the day to be added over there.

These are the Home Arrangement & Profile Arrangement:

profile arrangement

Here are the blocks:

Please help, what blocks can I possibly use?

TinyDB

Clock with 24hr Format.

Can you please show me how?

1 Like

Wait a Little.

1 Like

@shashank, We usually lead the way. And the user usually tries to do something. Generally, after trying and failing, the user asks for help showing what he did.

1 Like

As @Rogerio_Rios Said Try Few Things.
if They Don’t Work.

i will Revert my Deleted Post.
it Has The Solution Blocks.

1 Like

It is part of learning: try, make mistakes, research … :+1:
@ADDYLIN you’ve already given the way forward: TinyDb…

2 Likes

Thanks, I will try and get back to you amazing people!

2 Likes

Hey @Rogerio_Rios & @ADDYLIN,
As per your recomendation, I tried using TinyDB to store all values and then use variables to get the total values, but it doesn’t seem to work.

Here are the blocks I tried:

blocks (5) blocks (4) blocks (3)

This is the error I am getting:

Please help!

1 Like

Change Value if Tag Not There of TinyDB To - math_number

1 Like

Still the same problem

I tried this now -

blocks (9) blocks (8) blocks (7)

I got this Runtime Error:

Use Do it to debug your code . As you set global variables most probably you get empty strings cause you have to use set distance_label text to one of the blocks below and then when pedometer stop set label text to get global variable . After that save it to tinyDb

image

1 Like

I faced the same error while working with TinyDB. You can use the logic where if user opens the app for the first time, then set TinyDB value to 0 (on screen Initialization). It will solve your problem. :wink:

2 Likes

i also preffer the same

1 Like

Yup. Coz that’s what heroes do. :grimacing:

1 Like