Looking To convert multiple blocks into one

Hello. I'm new to this asking for help. I am learning on my own and have been taking notes from all the different questions on this site. One thing I need help from is how do I (shorten, compress, substitute) many block sets of close to the same down to a few blocks. As you can see below, the blocks are for button71. I have buttons 00-99, each with the below sets for each number. The app works fine if I only build 02-75 buttons. but buy increasing now to 00-99 it is having memory problems, and crashing which i am not sure is my computer which has 12gb, phone which has 8gb, or server. I know that there must be a way to take each block below and for example block2 that looks like a comb I have read on this site, and make just one set of blocks to take the place of the 00-99 that I have. I even tried breaking it all up and put 00-09 on screen2, 10-29 on Screen3, 30-49 on Screen4 and 50-99 on Screen5, but that did not help. In advance Thank you for your time, in helping this old man out.


block1


What is the app supposed to do?

For a sample of how to use lists of components with AI2, see

Are you sure you want 100 buttons ? You can used one listview or one listpicker instead...

3 Likes

I'm retiring from being a boat mechanic after 42 years. Since I am trying to learn this app building I thought I could build one to help me. I am storing all my tools in tubs, for now. Each button is numbered and the number is painted on the tub. After pressing a button it will bring up a list view for that numbered tub, that is stored in a tinydb under that tub number tag, so I can type in what is going in that tub and keep track of where the tools are, saving the list view in the tinydb again under that tub number. Once that tub is full the app will print the list view to pdf and save on phone so I can print out the list and put a copy in the tub. I have a lot of specialty tools for all the different boat motors.

That sounds like a two or three column table with columns:

  • tool
  • tool category(?)
  • tub number

AI2 has a spreadsheet component that works with Google Sheets, perfect for that, and filter capabilities at the spreadsheet and table (list of lists) level.

You don't need 100 buttons for this.

You can use an Any Component Block to run the appropriate action for each button. A lot of buttons though. I have in the past made an HTML page with the buttons on instead. That was for a project where 50 CCTV cameras were being controlled.

Example:
ManyButtons.aia (3.8 KB)

HTML Buttons Example:
HTML_BUTTONS_50.aia (3.4 KB)
Buttons50.txt (5.8 KB)
(rename Buttons50.txt to Buttons50.html)

I have been using this block for sorting and saving data to tinydb with tag10 for button 10, just fine. Having one for each button.

I then changed it up to just the one below blocks to take the place of all the rest of the ones above. It seamed to work fine while using, but when I close the app and then reopen the app, all the data is gone NOT saved.






I must be doing something wrong.

Thank you all for you suggestions. I tried using the any component blocks which seam to work fine for simple things like changing text, background, visibility, etc... But I can't figure out how to use them for lists, tinydb - tags for saving data from listview. When each tag in tinydb is named differently, and each tag is saved under a different global list. unless i don't have to save each tag under a different global list. I think i will try that next.

Looks like you also need to find and use the built-in sorting blocks for lists...

You may shortly get a lecture from one of the other Power Users about "combs", data and not repeating yourself. :smiley: You have already identified this as being an issue. Seriously think about getting rid of your 100 buttons, 100 variables, and your duplicate tag list, and make the lists work for you using listviews and procedures.

Show an example of a few entries, e.g. tub number, tool, category, etc. We can help you from there.

3 Likes

http://www.appinventor.org/bookChapters/chapter21.pdf

Try this:

tubs.aia (11.6 KB)

You will need to add some tools to begin with, then you can use the Show Tools button to view in a listview. The filter Tub will present you will all the items in just one tub. You can edit or delete items by pressing on the listview.

I use a single tinydb tag for all the tool data, using a flat file database, each record has its own trackable id, which then allows for two of the same tool in a tub, if required. I realise now I have only allowed a tool move to an existing tub, not a new one, so this will require adding a new tool to that new tub first.

BLOCKS

VIDEO

1 Like

Thank You So much.
Simple, Brilliant, Simply Brilliant. using List Pickers. OK. I will continue to study your block so that I understand them and how they all work together. Thank You.

2 Likes

3 posts were merged into an existing topic: Give some tips to create an app that has options to get ecommerce selling data like 1) Product Name, 2) Product image, 3) Price etc