Sequence of Screen and Variable Initialization

When my app starts, I'd like to load a couple csv files from media into lists, then create a list of those lists. Separately, these blocks all work the way I want. But they don't work upon startup.

The list spinnerList gets filled with nothing in positions 1 and 10, but all the "blank" entries work properly. During Screen1.Initialize Spin1_List and Spin10_List are not yet filled, and so the parent list does not get properly filled.

How can I load spinnerLists upon startup?

Why not create a procedure called addtolist or something that contains the set spinnerlist part from your initialize function. Then call it in the initialize function and called it in your filespin.got text blocks. That way as soon as information is avaliable it will update the list.?

The initialize function will always run first even if data is available so you need to update the list when information is there.

Your blocks do not work, because the file component works asynchronously, which means, the set spinnerLists block will be executed before your GotText events

Taifun

Got it. I will do what @Joel says and add each list to spinnerLists as they are retrieved in the GotText block. BUT, need to know when spinnerLists is filled with all 10 lists before proceeding. Best way to do that?

Again create a procedure called something like check lists. And in that procedure run a for loop from 1 to 10 and for each number check that that index in list is empty or not. Then call that everytime something is added.

Use only one file component, put the names of your csv files into a list, read the files one by one and delete the name of the current csv file from the list... if the list is empty, you read all the files...

for an example of asynchronous processing see also App Inventor Tutorials and Examples: Webprefetch File by File | Pura Vida Apps

Taifun

To be on the safe side, like so:

3 Likes