A function returning file contents?

you have to read my previous answer in the context... you said "The alternative is to split a very large block into many blocks all containing huge amounts of duplicated processing" so if you follow the DRY principle of programming you already know, that duplicating blocks is NOT the way to go but to use procedures.

You are looking for "a function to return the contents of a file as a list"
Later you said "The result is required inside a loop which is inside another loop."

Let's assume, someone is so kind to provide a function to return the contents of a file as extension for you... then this is a fake solution, because reading a file always takes a little bit of time... and to use this inside a loop, which is inside another loop might result in a runtime error after a while, because the processing is blocking the UI thread...

As it already has been said several times here in this thread, in the App Inventor world this is not the way to go. You have to think differently... I like what @ABG said earlier

so for your project let me summarize what we know after 63 contributions: you have some files which have to be read and some processing must be done... your screenshot you provided earlier is completely useless, you already know it...

if we take the analogy of the factory, the raw material will be delivered by trucks separately (these are your files), the trucks will be unloaded and the material will be stored in the storage unit (which means each file will be read and stored in local storage, this can be TinyDB for small data or SQlite database of more complex data)... the delivery of the raw material is independant of the processing later...

then when we start our processing, for example to build our car in the factory, we get the raw material directly from the storage, we only have to make sure, that all the material we need is there... what we do not want to do is to send the guys for example to the tire truck, unload all the tires until we find the AT tires we are looking for and then mount them onto the car...

I hope that helps to start thinking differently...

You finally might want to follow the guide How to ask a question (open new topic) and provide the missing information which is needed to get better help.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

2 Likes