I don't understand what I am doing wrong and am looking for someone to point me in the right direction.
I am building an app that has a login screen. I have two Firebase DB's one stores the number of users, and the second stores the user data. I believe that I have created the user data correctly, and here is a screenshot of the data structure.
The blocks I used to store the data and the blocks for the login routine are here:
I am wanting to have the user enter two numbers to login, the first is a user number that is supposed to correspond to the index number of the user data. My first screenshot shows 3 users, user number one, two, and three. The second number entered by the user is a private PIN that they set.
I do store a data set called User_Number in the user data because I cant seem to get the list index number part to work. I would prefer to use the list index instead of storing User_Number in the data but either way, neither method works for me.
When I test, I do not get the ShowAlert messages never fire even if the data is wrong. Is my data is set up the way I want it to be? How can I make this work?
In my previous posts you can see where I define User_Data .. I use a Make a List block followed by a Make a Dictionary block (see example blocks in my first post).. is this a mistake? I would think the Make a List block would convert my dictionary to a list .. but I cannot use the List version of Look Up in Pairs block at all, because its not a list after all?
When I use the Get Value at Key block from Dictionaries it generates an error:
Lookup in pairs: the list ({"ChatName":"Rusty","PIMs":0,"PIN":"8462","Points":0,"Unused07":"7","Unused08":"8","Unused09":"9","Unused10":"10","Unused11":"11","Unused12":"12","Unused13":"13","Unused14":"14","Unused15":"15","Your Name":"Mabel"}) is not a well-formed list of pairs
This is the correct line of data so I know my INDEX routine works. I don't know why I don't have well formed pairs when I used the Key - Value blocks to create my data. I am trying to pull data using the key PIN .. what am I doing wrong?
Since this is a list of lists of sorts, is that my problem? There is no Key named PIN because its only looking at the top level of the data? I am so confused..
An ephemeral variable like value is gone before Do It can grab it.
Set a global variable debug_value to value when a new value arrives, and apply your Do It to a get global debug_value block to see its vapor trail.
Now it returns a json list as string. Decode it and extract the first item of the list and you can access the list of pairs. (The .JsonTextDecode block can be found in the web component.)
If you have worked with javascript you will probably have come across jsonParse and jsonStringify, the blocks jsonTextDecode and jsonObjectEncode do the same things respectively (their naming appears a bit backwards, but comes from the naming in java)
You will also find that, in many situations, list blocks will work with json dictionary objects and dictionary blocks will work with AI2 list objects.
Keep that ShowListsAsJson ticked. It is ticked by default when you open a new project.