MIT App comparing Clock1 and TimePicker1


Hello all, I am very new to MIT App inventor and I am working on a App which requires me to compare the timing of the timepicker1 and clock1. I would like to make it so that if they have the same time it would change Label7 to ok. I have tried it but Label7 seems to remain as no.
(IOS)


grafik

I dont understand why the right side is giving me dates :sweat:

The right side is not only giving you dates, it is showing you the internals of the Instant you got from Clock1.Now() a while back.

It looks like the iOS version of Clock.Now() returns a bunch less text for an Instant than the Android version of Clock.Now(), which would fry your eyes.

If you are going to compare moments in time, you have to format them the same way, hours vs hours, etc.

How often does Clock3 fire?

Hello thanks a bunch! It works now but I do have another question regarding the delete button, as of right now I would have to refresh the whole companion app for the list to be deleted. Is there a way where the companion app would refresh by itself when I press the delete button? (I am using TinyDB as the storage)

Make a new procedure named Refresh, to be called from Screen1.Initialize and the Delete button.

Fill it with all the commands to clear things like global variables and TinyDB entries.

1 Like

Hi again sorry for the late reply had other project submissions, I tried doing it this way but the screen would not refresh, cant seem to find the problem :sweat:


(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.

export_and_upload_aia

.

PhoneProject.aia (7.4 KB) Thank you so much :grin: sorry for the trouble

I misunderstood what you wanted to refresh.

You had lost track of three different versions of the truth of your medicine schedule:

  • TinyDB tag/value TimeTable
  • global variable TimeTable
  • ListView1 Elements (a copy of global TimeTable)

In such situations, you have to decide where the truth resides.
I chose the TinyDB tag TimeTable, the one that matters when the app is closed and opened.

I added some procedures to enforce that truth for you:

This function returns the truth:

This procedure keeps ListView1 up to date:

Unfortunately, TinyDB does not allow us to operate directly on its values, so we have to pluck our TimeTable out, put it on the kitchen table (the global variable TimeTable), do the insert, and replace it back immediately to TinyDB, then let the refresh procedure update ListView1.

We have to do the same thing in the Delete button:

Screen1.Initialize is a good place to refresh that ListView from TinyDB too.

The source file:
PhoneProject1.aia (7.5 KB)

1 Like

Ahhh I understand now thank you so much for helping!! :grin: :grin:

1 Like