Weird problem when initializing screen

I have a weird problem. When my screen initializes, i get the error "Select list item: Attempt to get item number 1 of a list of length 0: []". Now I understand that this error means that the list is empty, but I actually have indeed put something in the list before calling Select list item. On the other hand, if I use the "Do It" function in the blocks editor, it works as expected. I believe if I upload the .aia file here, it will be easier to figure out the problem.

DataFile_Handling_Test.aia (4.7 KB)

Try this: (eg Timer.Interval = 100)

Can you please elaborate on why this is happening?

It seem to take some time (millis) to read the file. Since there is no DataFile.Read event, you can use a Clock component.

Thank you very much. I will keep this in mind.

Does it work for you. Otherwise set the Timer.Interval = 200 or 500ms.

That lack of a completion event is disturbing.

I wonder if the DataFile component needs to be hidden under the Charts component hierarchy, like a data source, instead of the Storage component pallette.

@Susan_Lane , is this component truly synchronous?

One more variation,

This hold true.

But can one be absolutely sure that a non-empty list already contains all list elements?
(Assuming the list is very long.)

For just this case only, case specific, code. Here, I mean to check that we have done with reading, content are in hand.

Okay ... my .csv file of dimensions 23 row by 12 col. I just checked that even a timer.interval = 10 works for the current dimensions. Eventually there will be about 2000 rows and same number of columns.

So would timer.interval = 1000 be a safe bet, or should I provide more time?

Why I ask this is because I am testing on a Redmi Note 10 which is decently fast. But users of my app may have a much slower phone. So in this case, what kind of interval should I give for 2000 rows of data?

I wonder if this component was meant for a different use case, where the data comes dribbling in, like a BlueTooth data stream feeding a chart?

But what kind of file would dribble in data in CSV format?

A Unix Pipe from another process writing out CSV rows to the file as it generates them?

also you can try like this (may be, so untill App reads the whole csv file clock will trigger with as much as short milli, and once got values clock stop triggers and generates the list what you designed)

image

image

If you know the length of the list, you can stop the timer when all list items have been read/assigned.

I would abandon the DataFile component, and switch to the File component, which has an event that will fire only when all data has arrived. The CSV conversion is easy, using the proper list blocks and a loop over the rows and columns to flip the table around its diagonal.

3 Likes

It should have a DataFile.Read event.

If you are really committed to this component, I remember an archaic technique where an extra record would be added to the end of a file to signal end of file and provide a summary or checksum.

That would be bending over backwards, though.

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