Sorting/Ranking Subtracted Numbers Error & How To Turn A Number Into A Word Tag

Hello there!

I am currently doing a personal project for school and I have decided to create a finance app using MIT App Inventor 2. I am almost done with the app but one of the things that I have problems implementing into the app is ranking the categories the user is spending on the most based on their inputs so that the app can show a message to the user on suggestions on how they improve their spending habits. I planned out how I could achieve this and pieced together a rough plan of how it would work.

  1. The app calculates the budget and actual amount of the user’s expenses for each category, it will make a list of the budget and actual amounts for each category.
  2. The app will then find the differences between the actual amount and budget amount for each category.
  3. The app will then rank the list from the smallest to the largest differences in budget and actual for each category.
  4. The app will then take that ordered list of categories and insert it into a temporary database.
  5. The app will then turn the differences in each category that it represents (Home Expenses, Utilities, Food, etc).
  6. The app will then display the text from the database into the notifier that will pop up.

However, so far I have only coded until number/step 4 but some for some reason, the app constantly gives me the same error message every time I tested it after trying countless times. It says "The operation length of list cannot accept the arguments: , [nothing]". I would really appreciate it if someone could kindly take some time to correct my blocks ASAP.



If someone still has time, could you please teach me how I can achieve step/number 5 on the list?

Thx :)!

You list items is either empty or a broken list. Ensure that all your textboxes are NOT empty, if you have no value for them, set as 0, do not leave them blank.

1 Like

None of them are empty. In fact, I have actually previously made a system that filled in any empty slots with a 0 based on past experiences. How can I fix a broken list? Thanks for the quick reply though!

There is a more block efficient way to do that:

image

(you will find the anyComponent blocks at the bottom of the palette on the left)

With regard to your error, you need to check your list of textboxes is loaded before checking the length.

1 Like

Oh thx for the blocks. But can you elaborate more about the loaded textboxes? :slight_smile:

When your app initialises, it uses the values in each textbox at initialisation to create the list, so they are probably all empty. You will need to set the values in each textbox and then generate the list....

image

1 Like

Oh, the function only activates when the user clicks the button. I have provided the entire project below so we don't have to keep going back and forth on the things that I have already included in the project. I may have also unknowingly messed up the code by activating other things at the same time. Here's the aia project (the "Monthly" screen is where the error is, sorry for the mess): The_Finance_Budgeter.aia (6.1 MB)

It doesn't have to, that is just my example. The important thing is to set the list at the correct time, when the textboxes contain all the values you want to use, not on initialisation when all the textboxes are empty.

1 Like

Like this? If so, it still pops up with the same error message :confused:


Also, what do you mean by correct time?

From your image, it appears you have all your textboxes with values.

Now is the correct time to generate the list items, then run the calculation.

1 Like

That's the problem, whenever I click calculate, it displays the error message... can you think of any other reason why my code is not working?

Here are my full blocks, you can try dragging and dropping this into an empty project

I do not see your rankjan procedure anywhere, or you building a list named items. Is that on another screen ?

Can you not see it in the far right hand side in the image of my blocks?

I just circled it in blue

1 Like

Ah, yes, didn't look over far enough. You do not appear to be generating the list with values in textboxes as I advised. Look at my blocks again, and build your list only after you have added values to the textboxes. As your blocks stand, your items list is full of empty values.

1 Like

Oh sorry didn't see your message, will try it out later thx.

Err... it gave me an error message.... have I done something wrong? Sorry for the long wait, just had an assessment week :confused: @TIMAI2


You are using the wrong list to set textboxes to 0, or you have included a non component block in that list

What do you mean by non component block? @TIMAI2