"Select list item: Attempt to get item number 2 of a list of length 1 ..." [SOLVED]

I need to set up a second item in my list, after loading from a file. My file is correct:

or I can do also:

For the moment, I don't know which is the best because I need now only a 1D-list.

But with the code that I have now, it doesn't recognize a second line or second item.
I tried so many possibilities after hours, but I still get:


However, if my source is like this, I can get the data out of it, because it is in a nice list:

How can I split up the text after the file load, to convert it in a practical list?

My save code (OK):
My load code is also OK.
My action after the simple load (NOT OK):

In your gottext event, remove the split text block. This is not needed, just set text to list from csv row.

1 Like

If u have put the blocks here in when screen 1 initialize no issue but as u have put when button 1 click the 2 items will be added to list only when button 1 click but in ur mobile if u din't click button 1 and went on to ask item 2 it will show error so first click button 1 , show full code to help more

I tried that already:

  1. Check what the data saved in the file in the phone memory looks like.

  2. Display the text read from the file in a label so you can see what it looks like after reading it. (show what the "output" label shows)

  3. Finally put your .aia project here so that someone can test it and find out what you are doing wrong.

I don't need to click a button to call GotText for profile_: it is loaded when I go back to that customer configuration screen if it has text.

Concept that I want: the user saves personal configuration data at the configuration screen to the internal storage. When the user goes back to that screen, his settings are loaded. (How I can convert text to numbers for more properties, will I know in the future.)

  1. I know how the data looks in the file
  2. I have a label for it: it's like it is saved, but not treated as a list
  3. This attempt with the got.Text doesn't give an error, but the selection forced on "2":
  4. I cleaned up my base file. Teeth_surface_timer.aia (89.9 KB)

Files written to:
profiles.txt (OK)
current_profile.txt (OK)
profile_[Profile name].txt (OK)

For testing: click for new profile or existing one -> Save -> click Settings button image to go back to the settings. Only current user, profile name, profile name list and 2 drop down options (Denture and Start side) are saved.

Why did you use a single-entry "join" block when saving the file? In my opinion it is also not correct ...

why are you storing the 2 values in a file and not TinyDB... this would make things much easier...
just store each index separately in TinyDB and later read it again separately...
no problems with storing and reading files, no problems with converting into lsits and csv tables

you can learn more about TInyDB in the tutorials...

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook http://www.appinventor.org/book2 ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro and the aia files for the projects in the book are here: http://www.appinventor.org/bookFiles
How to do a lot of basic things with App Inventor are described here: http://www.appinventor.org/content/howDoYou/eventHandling .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor


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

Agreed tinydb would be easier, but if you need to save to file, perhaps try this approach:


Good question, altough I don't realy need online savings and the functions TinyDB is new for me, but it shouldn't be that hard.

I composed now a kind of list output like Label1.Text, but I still don't know how to distribute that outcome to my different input elements because it is not defined as a list to apply the select list item list function. The result looks like the get text, but it embraced each row with [ ] now.

These blocks show how to return the the first [set] in the list, and display the values in individual labels


1 Like

I really love this solution :heart_eyes:: it clarifies me also how to handle a "2d array", or if you want me to say: a pack of composed lists :nerd_face:. I don't need 3D arrays for my project :ghost:.

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