This is more about the asynchronous logic used by AppInventor.
When you use the .GetValue block, the output is returned in the .GotValue event. You can't do anything with the value you want until you have got it. If you try to do other things with your intended value before you have got the value (which is what your save and second read procedures are trying to do, you can then expect data or program errors. You do not show your entire .GotValue block so I can only guess at what you are trying to achieve....
I understand your point, but if you look at the blocks I posted above I think I have that covered. My 'readCCUserData' procedure calls the GetValue event.. which in turn calls GotValue .. so I have the data at that point, at least this is my understanding.
At one point I even placed a Notifyer ShowMessage block in the GotValue routine after one of my variables to show the value after it was read in and it was correct. That block has since been removed..
I then edit the data pair that I need, and when I check, it's successful.
I then run the 'saveCCUserData' procedure to write the data back.. same as before.. that procedure creates the updated list and calls the StoreValue event. When I walk through this in my head, it should work fine. I then read MY user data back in and continue on..
I don't know how else to explain the logging in stuff. I login with my account (user number 1) and want to edit the data for another user .. for the sake of example, user number 2. I am using the user numbers for my indexes and tags since they are the same. User 1 is Tag 1 in the database, etc.. that just made sense to me.
I hope I am making myself clear, this is obviously not my field of expertise.
Here is the entire GotValue event. I did not include the whole thing before because of the size. Its small now so I could get it to fit on the screen. As you can see the data structure coincides one to one with the SaveData routine.
I asked for some at the beginning of this entire conversation.. that's what got this whole thing started. I will figure this out if it's the last thing I do.
You are inside a procedure or function that requires an input. App Inventor offers you the opportunity to enter an input so that you can run the function/procedure to get a Do It output
After reading the above article AGAIN, I decided to scrap my current database structure and start from scratch. I can see the advantages of this more 'flat' structure compared to what I was trying to do.
Thanks ABG for pointing me in that direction.. I think someone else also posted that link at me earlier, thanks to you too!
So I dumped the old database format in favor of something that I understand is called "flatter" than my old one. I do understand the design and it makes sense. It will be easier to edit the fields one at a time I think, which was my issue in my old version. Here is part of what I have so far..
This is the new user creation routine where new users can login and create their account. They fill in 3 fields from the design page, their username, their password, and they choose a chat name for when they are communicating with each other in the app. The other two variables are defined a value at sign up.
I am having some issues though, the Append blocks are not adding anything to my database. I thought well since this is brand new and there is no data, maybe there is nothing to Append to .. so I made a little StoreValue routine to create data.. That data created just fine but my appends still don't seem to add data. Thats one issue..
Second I am getting this error when trying to see if a username already exists in the database:
This is supposed to be looking up and comparing usernames but it doesn't?
Which led me to my third possible issue.. In my old method, someone pointed out that I needed to use the JSONTextDecode block from Web1 .. am I having the second issue because I do not have that block n my routine?
Regarding your parallel list structure, I find those very fragile.
They require you to keep all those lists in perfect sync, at risk of mismatching items down the line if you slip a gear. WHat if an item is empty or its insertion fails ?
It is more robust to keep attributes of an object together with tags, regardless of extra storage cost.
Regarding initialization of FireBase lists, you have to write an empty list to the tag value before you can do your first append to that tag.
Users are not an appropriate thing to keep in lists. Better to keep your user collection as an object with tags of unique user names, and each user tag value is an object with all its attributes, by attribute name.
That keeps all information about any particular user together.
If I understand your suggestion correctly, you are saying to use the user name as the tag, and the rest of the data would be the values? Something like in this example:
OK I am stuck again. I like the idea of the data structure you mention in your last post, above. I can see the merits of it from reading all the other posts about DBs and the problems that other users have run into.
I am setting my bucket to 'Users' and the tags to the users' name .. its the values that I cannot seem to get right now. It's easy if there is only the one value but when there are multiples I cannot figure out the blocks. Is it some kind of list? How do I do this?
Hear that? That's frustration setting in once again. I understand the concepts, it's the execution that I can't figure out.