I need know where the dictionary blocks. And the option if not possible use it.
Hi @caleberuivo4lgg6q, what do you mean by dictionary block? If you mean some sort of block where you can submit a word and get a definition, Thunkable does not have one. But, you can use a Web API as an alternative. Here are some dictionary Web APIs: Oxford Dictionary or Merriam-Webster Dictionary. And here is the Thunkable Docs for Web API.
Hope this helps!
What I’m trying to get to what kind of dictionary does he want?
I’m trying to get to the point
There isn’t an actual dictionary block. You could however use a json file or use two separate lists, get the index from the first and grab the corresponding item from the other.
What exactly do you need a dictionary for might I ask? Maybe there are other ways to go about this.
I’m assuming this is a dictionary like you would find in Python and other programming languages.
Yes. I need store key and value in a list, and after return the value if the text inserted in the textbox = key.
I think I get you. So…
If the user of the app won’t be appending to the dictionary locally, (i.e. you will be defining the data manually in the app) you can use a LocalDB.
Alternatively, you could have two stored lists: (e.g.
var listKey &
var listVal) Each list’s index must coordinate with the other. So you would search for the key, grab the key index(s), then return the corresponding value(s) using your index(s). The potential flaw with this system is one list falling out of sync, which would be catastrophic. Thinking of this makes me uneasy, though it’s a viable solution if you must record the users data and store it.
An option that I would recommend is creating a JSON in app, using a stored variable. I am unsure if this would allow you to delete attributes given the available blocks.
You could also do something fancy with tuples but I can’t see of a great way to do this in Thunkable.
To solve your problem, you can use a list of objects or a set of object properties. What to choose? To do this, you need to understand the functionality of the data structure. The list allows you to work with indexes and perform various operations in a simple way (add, delete, search, etc.), and the advantage of a set of object properties is directly accessible (as in an associative array). But this method is only suitable if the keys are unique.
If you need maximum performance, then the eoinparkinson option using two lists is good. But in addition to this, you will have to think about optimization.
FYI, dictionary in AI2 and Kodular = object in Thunkable X
Key = property name
Use a variable in property object and value is possible?
Can you explain more?
Variables can be set to anything.
Example of a dictionary that is created manually. But you can create a dictionary automatically from a string with JSON.
I had the same issue (Generating/ changing JSON object - #12 by drted). The solution I originally created worked EXACTLY like dictionary blocks in App Inventor 2.
Unfortunately, Thunkable changed variable handling in some way in April/May, causing my recurrsive functions to no longer work. I have a second version that works using a loop instead of recursion. The block “Syntax” is a little clunky now, but at least it works for both GET and SET. The working project is here: