Medication Reminder (again)

It's fine, by the way, it's portuguese not spanish but it's very close... Anyways, can you help me with this other problem?

Additionally, there's another issue. On the screen where you add medication, if someone sets the alarm for a time that refers to the next day (like 4 AM when it's currently 4 PM), the alarm will go off immediately because 4 AM is earlier than 4 PM.

yes of course the problem still persists, because it occurs in the Clock Timer event... up to now you did not update it...

here is your to do list again

So to fix your problem all you have to do is to detect the next alarm time from the list TinyDB.GetTags and use that time in the Clock Timer event instead of the latest picked time as you are doing it currently
unknown

Taifun

And how exactly do I do the "detect the next alarm" part?


Is it just this? Am I missing something?
And what about that whole "If the alarm time is lower than the current time then add a day"?

Well, you are again putting blocks randomly together... is TinyDB.GetTags an instant? And if you do not know the answer, then what about using Do it to find it out?

Screenshot_20240706_060904_DuckDuckGo

To be able to find the smallest item in a list it is helpful to have a list in a format, which is easy to sort...

In your case you have alarm times as items
The alarm time could be stored for example as millis (milliseconds) or in a format like yyyy-MM-dd HH:mm example: 2024-07-06 06:21 ( current time here in Costa Rica)

For the available patterns see here SimpleDateFormat (Java Platform SE 7 )

Then just use the sort list in ascending order block from the list drawer to sort the list

http://ai2.appinventor.mit.edu.ezproxy.canberra.edu.au/reference/blocks/lists.html#sort

The first item in the list is the next alarm time you are looking for

You could write a procedure for that
http://ai2.appinventor.mit.edu.ezproxy.canberra.edu.au/reference/blocks/procedures.html

You do that before storing an alarm time in TinyDB

Taifun

This is overwhelming for me. I'm giving it my all, but I don't feel capable of handling everything at once. I'm struggling to figure it all out.

What shoud I put on the comparison? How do I sort the list in ascending order with the blocks in the guide? And should the procedure do? I'm soo confused...

So which format did you choose?
Show us a screenshot of a TinyDB.GetTags block together with a Do it result

Use the companion app and Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Taifun is recommending you redo a major part of your Project to achieve a new feature you want You probably don't have enough time to do that and submit your Project on the 9th; so don't add the feature. Instead get all the other parts of your app to work.

I doubt I could do all he is recommending in the time available. :thinking: and am not sure I could implement his advice.

Do what you can. And provide a screenshot of a TinyDB.GetTags block together with a Do it result as Taifun requests. After you do it perhaps he will provide some Blocks to help you. Provide a screenshot oof the GetTags, not the format you provided.

The format is: dd-MM-yyyy HH:mm(that's the one we use here in portugal)
And the Do It printscreen is of the get tags in the listview screen, right?

That format is not useful to sort...
You have to differentiate 2 things, 1) to store the data and 2) to display the data
And you always can convert data from a format as it is stored to a better readable fornat to display it

It does not matter from where

Actually I'm not doing that
And for the record, this was my suggestion already a few days ago

To get the smallest item from the list you put 3 blocks together like this

  1. Select list item (to select the first item)
  2. sort list in ascending order
  3. TinyDB.GetTags

Taifun

image
Here is the result of the get tags

Ok, very good... you have stored currently one alarm time...
Now as already said..

What about storing millis in the database? This would make it very easy to sort... and to display it in the listview, you convert it into readable format

Taifun

Soo transforming the alarm time into millis?

Soo instead of this...


Having this?

Yes exactly
Very good!!!

And if you want to consider this

Then add the if statement again

And use the GetMillis blocks there

Taifun

I didnt exactly understand, can you explain it a little better?

Your blocks are correct, but do not consider the alarm time < current time problem

From my screenshot remove the blocks marked with a red x and replace the blocks marked with a yellow arrow by Get Millis

Taifun


Is this correct?

Yes
Now clear TinyDB to continue and find the next alarm time like this

unknown

Taifun

I'm afraid that I'm not finding the correct blocks... may you please sent a printscreen of the blocks needed?

the list blocks are in the list drawer and the TinyDB.GetTags block you alaready know
Taifun