Getting started

Hi

I’ve built a couple of simple apps for my personal use and the problem I always have is getting the project started. Once I have an outline, usually by looking it up on Google and using that as the starting place if I can find something like what I want.

Today I’m stumped as I can’t find anything like what I want online.

I’m not asking for someone to do the work, just get me started.

I’m trying to make a calories consumed app for my own use. I want to record foods and their calorific value and then be able to choose them and add them to a daily total i.e

Store these items and their value:

Fish 200 calories

Chips 400 calories

Peas 30 calories

Then say I have Fish and Chips but no peas, I want to pick Fish + Chips ( 200+400 = 600) and display the result.

Anyone willing to give me a starter on how to do this?

Rex

This project has a similar data structure:

It uses money instead of calories, but otherwise it's what you could use.

Thanks ABG this is just what I was looking for! This is how I usually do it, look for something similar and adapt and I think this will work!

Thanks again

Rex

Hi ABG

I’ve managed to adapt your aia so first thank you for your starter. I do have one follow up question - what blocks would I need to add to enable removing just one item from the tinydb.

Regards

Rex

In this section

the tag of the selected sale item is set up in lpkFruit.Text, so all you need to do is add a Notifier request (2 buttons) to that event asking if the user wants to delete the tag/value from the sales Namespace.

Have the deletion run in the Notifier response event, after checking which button (Delete or Keep) the user pressed.

I’m almost there. It removes the item but then produces an error I don’t understand.

Attached is the full aia.

Foods1d_copy.aia (216.6 KB)

Let's clarify ...

  • Remove an item from the menu, or
  • remove an item from the cart?

I looked at your blocks, and you have strayed far afield into Generic Notifier territory.

Here are ways you went wrong ...

This is how List Picker Elements are generated for sale items.
The item type is at the front, separated from the rest by a ':'.

lpkSale's Elements are generated from the describe value procedure, so that determines what you will get back from lpkSale.Selection

After picking a lpkSale item, you go wrong:

  • You split the Selection at ':\n', but there is no '\n', only ':' (remember the describe procedure?)

  • You set the wrong lpk Text. You want to set the lpkFruit Selection and lpkFruit.Text to what was extracted.

This is way off.

  • You need to have renamed Notifier1 to a specific named purpose, like ntfRemoveSaleItem, to express its sole function and allow for addition of other Notifiers later on, with other purposes.
  • You used a Generic event instead of a specific event. WHat if another Notifier need to ask a different yes/no question? It's a pain to juggle them all in one Notifier event.
  • The component parameter in a Notifier generic event is a Notifier component, not a list of items. You're just making stuff up at this point.
  • There is no TinyDB_Purhases tag 'lpkFruit'.

Delete the Notifier. This needs a rewrite.

P.S. You set a daily limit.

Does this mean you want to log daily calories by date too?

Here's a rewrite.

I went through all the components and procedures and variable names, renaming them for the application purpose. This was confusing enough as is, without the complications of ghosts of applications past haunting it.

Never be afraid of renaming something in AI2. It renames all uses.

I switched to immediate update, with a -1 button in addition to a +1 button.

Considering you're clearing the consumption db at end of day, that's all you need.



Foods1d_copy_20260417_163534.aia (215.9 KB)

OMG!

I can't believe you had the patience to do this!

While I thank you for all this it's firmly put me in my place, as to be honest, I don't even understand most of your reply.

I think this will be my last attempt at making an app as I obviously don't know what it doing.

Again thank you for your help and patience I'll just take your resolution and quietly remove myself from this space as I'm not up to the task.

Don't give up, it takes a while to digest.

Here's some introductory material so you don't have to dive into the deep end.

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook App Inventor 2 Book: Create Your Own Android Apps ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.

There is a free programming course here Course In A Box and the aia files for the projects in the book are here: App Inventor 2 Book: Create Your Own Android Apps

How to do a lot of basic things with App Inventor are described here: How do you...? .

Also do the tutorials Our Tutorials! to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

1 Like

Thanks for the encouragement, I just feel very stupid sometimes and get embarrassed, feel I am bothering people and making a nuisance of myself.

I’ll keep going……am on that subject……I want to import a csv file that will import txbFruit and txbUnitPrice into TinyBD_Prices.

I tried this but I get an error!

Glad to see you back.

AI2 lists start at 1, not 0.

P.S. If you find your imported data covered in quote marks, there are list blocks to transform CSV table text into AI2 tables (lists of lists), removing the quotes in the process.

Hmmmm

Changed values to 1 & 2 but now get a message that says CSV text cannot be parsed as a row. Cannot parse text argument to “list from csv row” as CSV-formatted Row.

Check the CSV text for short rows and headers.

There is a Length of List block you can test to skip rows with less than 2 items.

But that would not stop choking on bad CSV.

Upload the file if you can't find the bad spot.

P.s. I use Notepad++ for industrial strength text editing.

DOH! You know I said I sometimes feel stupid? Well your reply talking about headers made me realise my CSV data didn’t have any headers. I put the headers in and it works, apart from also adding txbFruit as a food item, but I can live with than for the convenience of uploading data.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.