RunTime Error using List Picker

I am creating a chat room app with multiple chat rooms. Everything is working fine except for one thing I cannot figure out.

I display a list of preconfigured chat rooms and allow the user to choose which room he would like to enter. They all work fine except for one.

The app is sports themed, so there are chat rooms for football, baseball, basketball, hockey.. etc. You get the idea. Again, they all load fine except for the baseball option. It generates the following error..

Error 01

Strangely enough, if you tap anywhere on the screen except for the error, the message goes away and the app continues on working normally. Tapping END APPLICATION closes the app.

Here is the part of the list picker for reference..

List Picker

All the other choices work fine, only when the user selects 4 for baseball is when the error appears. I have tried using the SELECTION block instead of the INDEX block to check for the users choice and I still get the error so the issue is either with Baseball as a choice, or it doesn't like choice 4 for what ever reason. Everything is configured the same so I don't know why it only happens there...

Notice at the bottom of this screen shot that when the user selects baseball from the ListPicker, it does change the name in the CustomRoomTxtBox to "MLB Baseball" just fine ..

Error 02

Any ideas?

instead of compare the index to every number, I suggest you to store the Chat room name in a list, then you can:

when listpicker.afterpick
set customroomtxtbox.text to select item from list(list, index);

Good idea. That's a lot more streamline as well, a LOT less blocks. Let me see what I can come up with..

I made the change .. it is a lot cleaner, but it still generates the same error. So the error is/was not in the AfterPick routine .. maybe there is something in the room data itself? When a user picks a room, it loads the Elements for that room. If something was corrupt there would that generate the RunTime Error?

upload your aia here, some PU will have a look.

More strangeness .. if you choose any other room, and then switch to the MLB room it works fine with no error. The error only shows up if you choose the MLB room first. That at least tells me the issue is not with the Elements of the room data or the error would persist every time you enter the MLB room.

What ever it is, this is beginning to sound like a bug of some kind..

If I attached my .aia file here, is it available for anyone to download or just for a Power User?

if you don't want to public your aia, you can pm me the aia. I will put it here with only PU can see it.

the aia you send me has too much blocks, please make a small demo which can reproduce this issue and upload here.

I will try .. this is a complex app so it may take some time.

keep the demo app as simple as possible.

Still doing my best to create a slimmed down version that will show what I am seeing, its proving to be a little tougher than I thought.

However, I did try a few things.. I changed the order of the rooms but that did not make a difference, so its not the fact that the MLB room was 4th on the list. It did not matter where on the list MLB sat.

I also deleted the data in the MLB room and created a new blank room, but no fix.. so it was not the data in the MLB chat room.

And it only happens if the MLB room is the first room chosen. Everything works fine otherwise.. and the error does not appear if its NOT the first room chosen.

Is it the name of the room? I do not know what else can be in common..

I checked the source code of App Inventor, and fond this error

"Expected a number for an index, but got \"%s\" instead."

only occured when you are parsing a Dictionary/List using key path params, so your problem should be like here:

when your gameData is a list, not a dictionary, you will get this error.

demo to reproduce this error:

I just figured this out on my own too.. now I just need to figure out exactly what the issue is so I can fix it.

I do not know a lot about dictionaries.. I am needing to use "events" as a key. If I understand what you are saying, I am not using "events" as a key but as a value instead? Is my mistake in using the "list by walking key path" instead of a different block?

make sure your gameData is a list or Dictionary.
If it's a list, the first item of the key path should be a number,
if it's a dictionary, the first item of the key path should be a string.

OK, here is the part I do not understand I guess ..

gameData is a Jason list of lists .. and I am wanting to search this list by looking for the key named "events". From what you are telling me, this needs to be numeric instead of a string? Or, more logically, I should treat it as Dictionary instead of a list because the data "event" that I need is a string..

All of this aside, why does it work every other time and only errors with MLB?

show an example of the data in gameData here, and what data you want to pick from it.

Here is a sample of the MLB data.. . If there is more than one game scheduled on any given day, its the same format over and over for each game. I figured this should be enough for an example..

jsonformatter.txt (477.3 KB)

Basically I am pulling the home team name, the away team name, the scores for each, and the time on the game clock. Thats about it. The data is used for a real time scoreboard that is at the top of each chat room. Each sport (NFL, MLB, NBA, etc) has their own scoreboard.

If the data I uploaded does not work try this link:

The link will be good for 30 days..

indeed you have an events key in the dictionary.

but you initialized the gameData as an empty List, maybe you call the walking at key path function too early before you get the real data from internet?

Now I really do not understand. If I do not initialize the gameData as an empty list, how else am I supposed to?

And second, I call for the data before this routine is used .. are you saying that by the time I try to use the data, it has not completed its download to me?

then check if the gameData is containing key events before pick it out.