A function returning file contents?

Because it can't be done... Prove me wrong.

Just tell me that you can tackle the challenge without telling lies -- that will be enough.

I once tried this experiment, but succeeded, but I lost that project.

I'm telling the truth!

I think someone would have been able to answer the question within three days if what you are saying is true.

You might consider using this.

I think it is already mentioned in this topic but I'm posting this anyways.

Receive the file path an open that using Activity Starter but get the path with this extension.

Why isn't anyone trying to get the main code-base fixed instead of making extensions to fix the giant hole?

So you think even creating an app for 3D Graphics (for example) should be fixed by MIT ?

Think before you answer.

One thing you could do is

Report the bug here:

I don't understand what you are asking.

I had looked at the extension you mentioned above before I first posted, but I don't see anything in it that deals with reading a file -- just accessing files that are difficult to get to from within AI2. I think it would still rely on the ReadFrom and GotText methods.

check the above post as a last resort.

Thanks. I'll check out the GitHub repo.

Seriously though, you said you (I think it was you, at least) would provide the blocks for the function a day ago. Did you really find an answer?

1 Like

I am not very well. So I couldn't send it.

One of my degrees is mathematics... It is always nice to have an existence proof up front, before spending huge amounts of time proving the theorem.

Did you manage to find an answer or not get around to it?

I said

Let me answer simply.

In the entire history of AI2 no one has done a synchronous file read.

I have monitored the help board, over its history, so I use that to answer your question with a "no".

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

App Inventor does not do that in a single function - I think you were saying you also needed the ability to read the file line-by-line or 'until' as you can in C/C++ for example.

Bear in mind that this is a free App development program, primarily educational, aimed at young people learning to write code for the first time using a novel interface first developed by Google. Our Technical Support is also free, we are unpaid volunteers - so you get a lot for your money. There isn't a programming language that suits everyone and everything, hence there are so many of them.

If App Inventor does not meet your needs and you don't want to help us enhance it, there is no need to rave here - use Java, Kotlin or one of the fringe languages like Spider Basic, B4A etc that have that functionality.

The last few posts finally admit to the problem I have been trying to point out. I had already concluded (in a post two days ago) that java was likely the answer since AI2 chooses not to handle this. Should somebody actually decide that it should be handled, I suggest going back and looking at the old tcl/tk (another free user-supported tool) event loop where a solution to this problem has existed for decades.

In the absence of a concrete example (that you didn't provide despite repeated requests :upside_down_face:), no one (except possibly yourself) might have learned anything from this topic.
(At least I don't.)

1 Like

From this thread everyone could learn the following:

  1. How to ask a question (open new topic)

  2. here in the App Inventor world you have to think event oriented

  3. Quote by Albert Einstein: “The more I learn, the more I realize how much I...” don't know

Taifun

3 Likes