Select list item: Attempt to get item number 17 of a list of length 0: ()

Hello !!

I am building a app to import from a csv file and show the values in the lables from the item selected in the slider.
In the Companion everything works fine but when i compile to apk and install in the cellphone show me this mensage: “Select list item: List index too large Select list item: Attempt to get item number 1 of a list of length 0: ()”

Can anyone help me to solve this problem?

Welcome :

“Reads text from a file in storage. Prefix the filename with / to read from a specific file on the SD card. for instance /myFile.txt will read the file /sdcard/myFile.txt. To read assets packaged with an application (also works for the Companion) start the filename with // (two slashes). If a filename does not start with a slash, it will be read from the applications private storage (for packaged apps) and from /sdcard/AppInventor/data for the Companion.”

I have tried without “/” with one “/” and nothing.
In the phone, the file is located in the internal storage in /Makeroid/assets/.
how can i set to search in internal storage?

Thanks.

Can you show the .CSV file? Perhaps it’s a problem with your file?

Also, you should optimise your code, the code in the function format can be shortened…

This is the csv file. I have to put in .zip to send.

Thankshyline_-_Sheet1.zip (1.1 KB)

I don’t know how but I think the function format is being called somewhere before the event File1.gotText takes place which means that the CSV list Table is an empty list (Its length is 0) and you are trying to get the value of the item at index week (which is 17) which doesn’t exist yet…

I agree with you. The file is uploaded (because in back) i see the values from week 17 but the error mensage is showed!!!
I tried to change the file location with “/” and without “/” and show another mensage " canot find the file…"

But why???

In an app to generate PDF, upload and then record on the smartphone I used this path. In addition to FileTools to create the directory I wanted.

filetools

/storage/emulated/0/meusphp/potato.php

One thing that i discovered is when “Slider1.Position Changed” block is disabled, the error is not showed and the values from week 17 are in the labels!!!

Where is this block ?

The problem could be…

The size of your CSV file is big which means it might take a little while(0.5 to 1.5 seconds) for your app to process it.

OR

The Slider1.Psoition Changed event is somehow triggered before the event File1.Got Text

OR

It could be that both the above mentioned blocks are causing this…

The strange thing is when i pass the aia file to Thunkable plataform and compiled to apk it works perfect in the phone. same inicial code.

???

I found that the issue is caused by the slider.
Can anyone share the SliderTools Extension v2 from ken. Is no longer avaiable from the links from Appybuilder!

Put everything in Slider1.Position Changed event into an If statement. Use the Is list empty block to check if the variable table is an empty list, if the condition returns false, execute the code.

If you still want the extension check here...

All Extensions From AppyBuilder Community [FREE] - Extensions - MIT App Inventor Community

Top Top Top.

It Works…

Thanks…

Good to know, also, pls don’t write in all Caps, it looks like you’re shouting…

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