Opening files, are they automatically closed

Hi
I'm using files1 for reading text files. I have 3 files for my project that need to be read at certain times.
Should I open all files first in screen initialization or as I have it right now each time I need to access the file I open it first.

I'm used to open/close files but I don't see a closed file option.
the code snippet below show's whenever I want to receive speech to text I open a file to compare the received speech.

I'm assuming APP Inventor open and buffers the file contents, then closes but that's an assumption.

Thanks

Screenshot 2023-02-26 094520

grafik

Hi thanks, Im not sure what your saying.

Only three files?

I would load them into TinyDB at first run, one tag per file name.

Then you can refer to the file contents directly through the appropriate TinyDB GetValue, with no interruption of your control flow.

Hi, thanks for your reply.
How do I copy the entire file to TinyDB

Thanks

Thomas

This is correct. App Inventor reads the entire file into memory and then closes the file handle before the GotText event is run, with the contents in memory being provided by the text variable.

Thanks, that's great to know.
That's one of the things on APP Inventor I'm not sure of, what falls through on calls and waits for handlers which I think is most of the extensions.

In .GotText event for File filStatePopulations
TinyDB1.SaveValue('StatePopulationsText', text)

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