Can we programmatically generate lists, such that we don't have to manually assign a new variable to each new list?

Hi There,
There is a principal that once your application is developed it will change the data but will not change the blocks you have.

We have our blocks to do the stuff like changing the data, appearance, calculation etc.

I agree that you need to save your different chats in different place at firebase. That has nothing to do with creating new list in the blocks for each user.

Instead you can make a main list like this:
Main List
Chat 1
Sentence 1
Sentence 2
Sentence 3
Chat 2
Sentence 1
Sentence 2
Sentence 3
Chat 3
Sentence 1
Sentence 2
Sentence 3

So you don’t need to create a new variable. Instead update the existing variable i.e. Main List


The reason I want to create a new list, is so that the new list can replace a specific chat (say chat 3), when sentence 2 is introduced. Currently, it is either, having the same list for all chats, or the new sentences replacing the old for me.

I don’t have a working example for chat right now but what i am saying is keep your variable floating.

Just assign 1 chat to it at one time and when you are switching to new chat before that just save your chat 1 to firebase.

So when again when you are chatting to a person in chat 1, first get all the chat saved from firebase and then update it.

So, 1 variable for all chats (1,2 and 3)?

Your variable one should be a list, which contains other lists say list 1, list 2 and list 2 for each chat

1 Like

I see, let me try that.

I think you need to do this to get your results.


When Button1 click, it will add item to list.

Hope it will help you. :slight_smile:

3 Likes

Ok Thank you. I am still trying something different. I am posting something else that is puzzling me. Please take a look at it if you can. It’ll be posted in several minutes

A very good way to learn App Inventor or Kodular is to read the free Inventor’s Manual here in the AI2 free online eBook App Inventor 2 Book: Create Your Own Android Apps … the links are at the bottom of the Web page. The book ‘teaches’ users how to program with AI2 blocks.
There is a free programming course here Course In A Box and the aia files for the projects in the book are here: App Inventor 2 Book: Create Your Own Android Apps
How to do a lot of basic things with App Inventor are described here: How do you...? .

Also do the tutorials Tutorials for MIT App Inventor to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

Taifun

3 Likes

Okay sure. :slight_smile:

1 Like

Thank you,I solved my own problem. This thread is about programmatically creating a list, it’s not quite like what you suggested but I did not use it in the end. But thank you. I appreciate it.

1 Like

Can you share the solution? So that other with same query/doubt can get help

It is a completely different algorithm. It would be out of topic here. That’s why I didn’t mark any one’s answer as a solution. The solution has not yet been found for this specific topic.

Did you read @Taifun suggestion.
You need to add variable in list on run time of app yes then use add items in list block to add in that list

1 Like

Your question is not entirely obvious.

Just fixed the title. :slightly_smiling_face: Hopefully it is more understandable

no i dont think so :rofl:

1 Like

ok, must have forgotten to click the checkmark. If it is still not understandable, let’s blame it on language barrier :laughing:

1 Like

Can we programmatically generate lists

yes, we can, see my previous answer

such that we don’t have to manually assign a new variable to each new list?

what about using a list of lists? you only neeed one variable in this case for the list of lists
and what about following the links to the list tutorials?

Taifun