Global variable that empties

Hello and good year
I have several folders in which I read the Mequipe.txt file. I create a list of the result of reading files.
In the GotText block my list is correct and contains the elements.
(1) I have 6 items read so 6 items in my list at the end of my loop

But once out of GotText my list is empty!
(2) Just after the ReadFrom block the same variable has no more element

1 Like

?? i don't understand your reply

Text blocks are only used to display the content of the variable. I use different elements to be able to compare.
If I do "Do It" on the blocks, the values are the same. but in the execution of the program it tells me that the list is empty from (2)

Post a simple test aia.

Your label Joueuers will be empty because File1.GotText has not yet happened. This was my guess from the limited blocks your provided.

It's complicated to give yourself an AIA test.
Here is the structure of my files.

Capture d’écran 2022-01-03 161220

My larger block

Part 1: I recover the MEquipe.TXT files in each folder Equipe1, Equipe2, EquipeX, It works.
If I do a test with a notifier in the "GotText", the ListMaillot variable in 2 changes. it's good
Part 3: I create my elements for a "ListView" and there the ListMaillot variable is empty in 4

It's impossible to load multiple files and handle their content in a single procedure.
The files arrive one by one, in their own events.

Set up a little factory floor of events and global lists or dictionaries to stash the incoming file contents in appropriate containers (dict/TinyDB) under a matching key/tag for later processing after the last of the files have completed their GotText events.

To feed the issuance of File Read requests one by one, you will need a global file name list to feed your File Read block one by one, deleting newly requested file names from the lists after their contents have arrived and have been stored separately.

1 Like

It's what i do, No ?
In part 1 it's my "little factory" and i save the result in ListMaillot (2)
the part 3 it's my process but ListMaillot (4) is empty

  1. Connect to Companion, right mouse click, "Do it" on this block (PathLocal):

  2. With the blocks partially collapsed, how should anyone there be able to help.

  3. Where is the problem to post a simple test aia?

Here is a sample app that loads 3 separate files, one at a time, before starting to use their contents to solve a puzzle.

Sorry for not having answered earlier but I only work on my app on weekends.
I solved my problem by adding a "timeout".
On the previous block:

It goes to (3) before having finished (1) or all the passes of (2). The variable when going to (3) is necessarily empty.

On this new block, with a "timer", I allow time to finish 1 and after that it goes to 2. It works.

It's amazing that he doesn't finish the whole of one block before moving on to another!

if MIT implement Anonymous procedure, this will be very easy like this


This is Java's fault, not App Inventor's (the latter is based on the former), due to something called the Stack:

1 Like

It's appropriate to a device that strives to juggle many tasks simultaneously and that allows its apps to also juggle simultaneous processes.

You don't want your app to go into little comas as it reads files, do you?

Anything that takes longer than a snap of your fingers should have a separate completion event, to allow your program or others to make productive use of the time between start and end of long (in computer time) processes.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.