Cannot figure out the Dictionary

I have been trying to get dictionaries to work of a while but every time they seem to fail.
I have made and dictionary with one pair. and copied and pasted the key into the search and it did not work
I have copied the example on the page on the dictionaries

I have made a simple one

And I even tried comparing it to the list version. to my understanding. The list look up pair and get value from key in dictionary are the same. Just compute the same thing in different from. But the list one works. but if it turn the list of pairs into a dictionary and use the get value from key in dictionary. It dose not work.

I have not been able to find anything about this.
Can I get some help on why they do not work pleases?

Welcome Jaxon.

There are a few examples in the Dictionary documentation http://ai2.appinventor.mit.edu/reference/blocks/dictionaries.html that might help you.

Please download and post each of those event block(s)/procedures here ...
(sample video)

For lack of your live blocks, I had to scribble on their pictures.
c7e35679005df952ba60caa1f93becb7b45bafac_2_690x434

Export your .aia file and upload it here.

↑ try @ABG s solution for this blocks ↑

↑ you are trying to set a label text to a color!! ↑
try setting a label text color to a color.

↑ 1. try using "1" and "2" instead of 1 and 2
2.try updating your android al companion app

here is a simple example for how to use dictionary:
we have a spinner here.
ElementsFromString : ,red,yellow,blue
Spinner Properties

Now we use these blocks:


here is the aia project
to learn more about dictionary, click here

1 Like

have try that

I don't see the component in the palette

and I was use a label so it should have worked and I also have tried with color values

I did a exact copy and it did not work

I added the dictionary but I was trying to search for Tim the Beaver, And I tried school to and it did not work

basic.aia (2.2 KB)
This is the download

Also why dose the initialize variable error when with a dictionary? feature or bug?



Capture2
Capture

basic.aia (2.5 KB)
Designer

This is how to get the school name.

the key xx value xx block is only making sense when it's connecting directly to the socket of make a dictionary block.

1 Like

I am still getting errors

Do you see the red X in the upper left corner of the init global examaps block?

Right click on that block and try to clear the error.

The error message is saying that the 'school' key is not found in the examaps dictionary.

Retype and reinsert the same school text block in the examaps and get value request, to make absolutely sure they match. Use the AI2 Copy Block to be sure. Make sure there are no leading or trailing blanks around the word school.

1 Like

I retyped school and name and copied them over but did not work could it be the device

What kind of device do you use for testing?

maybe the error is from here(that wasn't making any scene for me before but Nishyanth_Kumar told me it does make scene) :


or maybe the value does not have to be a integer
8ace682a403418277c4376a18f060bbaa

and because of these (or something else), global examples has an x and that means it will return nothing and nothing is not a dictionary

and your trying to get a value for key from nothing

now see the full image:

solution: maybe use text instead of math_number or maybe this is making the error or maybe you have to update your companion app

try to click on that X show us the message

This is a perfectly valid dictionary instantiation; it's a good example of nested dictionaries:

I hypothesize that OP's project and/or blocks are corrupt.


Even if examaps isn't recognized as a variable, it should result in a compilation error, not a runtime error.