Flight time Calculator

Try this extension:

I don't need any time zone conversion, it's just a calculator to add or subtract multiples flight time HH:MM from a logbook.

For example I put in the read only textbox some values using the keypad and the textbook should show all the calculations and the result.

01:30
+
00:30
+
00,30

Total is 02:30

Its just a simple calculator but my knowledge with programming is still weak and I don't know how to build the code in MIT app inventor.

Here's a version using generic blocks and value procedures:
Calcolatrice.aia (1.8 MB)

Thanks guys, I try your solutions soon and I let you know

If you need a running sum, also see

Thanks man is working, now I can study and learn from it.

Thanks again, guys, for your help!

I've made some code changes to allow infinite addition or subtraction.

  1. Now, I need to display the entire history of the expression in lbl_textbox after pressing =, better if in one line,
  2. and it would be even better if the user could see what is written before pressing = for the final result.

Currently, after pressing the + or - button, the lbl_textbox is cleared, so the user has no feedback on the progression of the full expression.

Do you think this is possible? Thanks again for your kind help! I'm learning MIT App Inventor and coding, but I'm still at an low level.

I've attached my .aia file and a screenshot of the error I get after pressing =. I hope this helps!

CALC_v2.aia (1.8 MB)

Go back and study the on screen components in my ABG_Mart sample.

Don't I do that already?

I don't undestad how to implement your file with my calculator.
Anyway thanks for your help.

If I want to fix at least one error (result not visbile and 00:25 reproduced 2 times), do you know why I get this error in the picture? what is wrong with my last changes in the code?

my input was 01:20+00:30+00:25-00:45

Before I dive into your code, I would like for you to familiarize yourself with
Reverse Polish Notation (RPN)
in its simplest form, without a stack.

That's the technique I used in my ABG_Mart sample, where the + button acted as an immediate command to add the textbox text to the running sum in the Label.Text.

If I had a - button, I would have subtracted the textbox.text from the Label.Text.

This makes it unnecessary to have a = button or Enter button, since the running sum is always available.

Your app might be trying to emulate a more complicated scheme, where you are mimicking math formulas. That would be unhelpful for this kind of calculator.

oh, yeah! your're right. Now I get it. Thanks

I implemented the "-" button as per your suggestion. The calculator works well, but it doesn't fully meet my needs.

I created a condition to prevent starting with negative hh:mm, but this condition doesn't work correctly when calculating a successive negative time. ex "05:00 - 06:00". Instead of displaying "-01:00", it incorrectly shows "0-1:0-0" in the "Result" label.

Additionally, the current input sequence is not intuitive. For example, if I want to calculate "00:30 + 00:50 - 00:25", the user must press the buttons in this order: "00:30+" "00:50+" "00:25-". This is not user-friendly. Instead, the sequence of inputs should be "00:30+" "00:50-" "00:25", and then an equal button "=" for calculation. The "equazione" label should display: "00:30+00:50-00:25 = Result".

Another problem is that the label equazione expand vertically, but I prefer that remain in one line and the user can scroll horizontally to see the entire equation.

Am I missing something here?
Consider I am at a very low level initial stage with mit app inventor and programming is not my job.

Aviation_Pilot_Base_Calcolatrice4.aia (1.8 MB)

You and I differ on our ideas for what is user friendly.

I model the app on the 1960 cash register in my family mom and pop grocery store.

You will only need negative numbers for correcting prior entries, right? (Unless you have a time machine, in which case contact me last week)

Maybe redo the interface to let the user roll back to a prior entry to fix it?

Time to learn lists.

ask user input like this, with no space, or you can replace all space and \n with "".
then check if the length is 6n+5.
then separate the string (length 5 +length 6+length 6+....) into a list
then sum up this list.

Maybe I'm not explaining my needs clearly. I need this app for myself and some colleagues to easily calculate the total flight time we've accumulated as pilots. Using a numpad we should easly add or subtract some hours.

Now, after summing up many hours, I need an "equals" button to finalize the calculation. I also need an option to subtract hours for verification purposes. Additionally, there should be a way to edit the current equation in case a user enters an incorrect time.

I've created the latest .aia file in an attempt to improve it based on your suggestions, but I'm completely lost in the code.

I know that we can have different point of view, but I need this function at least because is not natural the sequence of imputs when we have to subtract flight time that are from a different category. Is not like the most common calculator.. The current input sequence is not intuitive . For example, if I want to calculate "00:30 + 00:50 - 00:25" , the user must press the buttons in this order: "00:30+" "00:50+" "00:25-" . This is not user-friendly. Instead, the sequence of inputs should be "00:30+" "00:50-" "00:25" , and then an equal button "=" for calculation. The "equazione" label should display: "00:30+00:50-00:25 = Result" .

the reason is to get a total flight hours, than calculate from the total only the hours at night or day etc by sutract some hours we have logged in the logbook. So I need to subtract but in a user friendly way. I hope to cleared better my needs. Thanks as always for your big help.

This is amazing!

You built a city with Blocks! :star_struck:

:pray:

Lito

@>-->---

image

I added a +/- sign Label to indicate positive or negative time, and switched to infix notation.

Try it.

Aviation_Pilot_Base_Calcolatrice4 (1).aia (1.8 MB)

ahahaha sorry man. As I said, I'm really new with mit app inventor. I know that with hard study I can do better blocks, but now I am very limited.

1 Like

Thanks @ABG :pray: :pray: :pray: , I really appreciate your help. I always study your files to learn. I hope to improve, I just need time.