Index operating incorrectly in a way I can't understand nor figure out how to fix


arnst_1_2_4_v3 (2).aia (11.1 KB)
Above I've listed an image of my code and a file of my code for interactive purposes, I'm doing this for school and multiple people have had this issue, but I can't seem to figure out why this error is occurring
error_message
This is the error that occurs whenever I try selecting a flavor and then selecting the vote button. If anyone could tell me what I am doing wrong, that would be great.

Try using a math if said item equals said item rather than the ones in the logic category.

When exactly does the error occur?
An index can't be a boolean value...


Taifun

This question already answered here:

seems you may be copying each others blocks :wink:

Hello Aiden

Note that your 'UnDo' should remove the last item added to the List, not the first.

If I add a flavour, the existing flavour in the List (chocolate) is lost.

In the ConfirmVoteButton click block, why are you testing if the chosen flavour is in the List? It must be in the List since the List is used to populate the ListView from which the selection has been made......

It is difficult to follow your code because of your component naming convention. You should not remove the component type name. For Example:
'ChosenFlavorOutput' should be 'Label_ChosenFlavorOutput'.

Two areas with issues:
Blue: The Vote List should be comprised of pairs [flavour,vote total]
Red: There is no guarantee that 'CombineLists' will complete before 'FindWinner' starts - instead, either set 'FindWinner' as the last call in 'CombineLists' or make each Procedure a 'result' Procedure (instead of a 'do'). Same issue with 'FindWinner' and 'FindTotalVotes'.

So how is it that your code is so similar to that of TheGamingBear (purpose and code), with similar errors? Is this a school coding competition?

It's not a competition, its a school related assignment which uses the program Project Lead The Way, which has MIT app inventor as it's coding program

Oh, no :grinning_face_with_smiling_eyes: , I tried asking my teacher for help and they gave me an example sheet which prior to submitting my code I fixed a few things, I can see how one could think that though, but nobody else in my class has consistently faced the problem I have during troubleshooting. I do believe it might have something to do with the Index as the amount of 0's extends and shortens with how many items I add to the list

Also something to note on, the program we use strictly tells us to use those names for each asset, as naming it something different would make it more difficult for grading purposes

This happens whenever I select a flavor, whether it be an inputted flavor or the already existing flavor of chocolate, and then click the vote button. From my (very) limited knowledge of MIT app inventor as I've only used it for 3 months in short class periods, it seems like the index values might be involved if the list of flavors is extended to more inputted flavors, the amount of 0's correspondingly increases

Also, I followed the information on this and it worked. Thanks for helping!

...and so you can, but retaining the component type name. If your Teacher tells you differently, invite him/her to the Forum to discuss with us.

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