The second argument to foreach is not a list. The second argument is: *nothing*

2,161 views
Skip to first unread message

Παναγιώτης Σκούρτης

unread,
Jan 4, 2015, 1:23:21 PM1/4/15
to mitappinv...@googlegroups.com

i make in a list with the listview and when i pass a certain number of inputs it gives this result The second argument to foreach is not a list. The second argument is: *nothing* with out passing the input number of 691 it works perfect. is there a certain number of inputs? or is a problem to my app?

Taifun

unread,
Jan 4, 2015, 3:01:19 PM1/4/15
to mitappinv...@googlegroups.com
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

Παναγιώτης Σκούρτης

unread,
Jan 4, 2015, 3:45:20 PM1/4/15
to mitappinv...@googlegroups.com
i have made a search app for dust bags in the first foto is the search button and the second is a part of the list(i can't post all the list is big) when i rich 692 inputs in the list and i try the app in my phone dysplays me The second argument to foreach is not a list. The second argument is: *nothing*  when i delete one  and i am back to 691 it works perfect! 
list.jpg
search.jpg

Taifun

unread,
Jan 4, 2015, 3:57:43 PM1/4/15
to mitappinv...@googlegroups.com
probably you found a limitation for lists? 
but why are there so many spaces in the list items? probably you can remove these?
what do you get if you do the following as a test:

  select list item get global items
                         692

Taifun

Παναγιώτης Σκούρτης

unread,
Jan 4, 2015, 4:16:48 PM1/4/15
to mitappinv...@googlegroups.com
the spaces are becose for some reason it gives a nice result in search. where i can find the ''select list item get global items'' and how i can give the 692 number? sorry but i am new!!!!!

Παναγιώτης Σκούρτης

unread,
Jan 4, 2015, 5:45:39 PM1/4/15
to mitappinv...@googlegroups.com
i can't find how to change that number

Παναγιώτης Σκούρτης

unread,
Jan 5, 2015, 4:26:30 AM1/5/15
to mitappinv...@googlegroups.com
anyone with the same problem or some short of solution?

Taifun

unread,
Jan 5, 2015, 7:49:23 AM1/5/15
to mitappinv...@googlegroups.com
you can find the select list item block in the list drawer
see also How to work with Lists by Saj
Taifun

Παναγιώτης Σκούρτης

unread,
Jan 5, 2015, 8:15:25 AM1/5/15
to mitappinv...@googlegroups.com
it is possible to post the .aia  file to take a look because i can find where is the problem with the list it refers the list as "nothing" when i pass 692 inputs? 

Taifun

unread,
Jan 5, 2015, 8:32:33 AM1/5/15
to mitappinv...@googlegroups.com
yes, but please remove all blocks and screens first, which are not relevant to this problem, 
the project should be as small as possible to demonstrate the problem
Taifun

Παναγιώτης Σκούρτης

unread,
Jan 5, 2015, 8:45:31 AM1/5/15
to mitappinv...@googlegroups.com
i prepare for you a test app to be smaller version. If you press now the search button it works perfectly returns the results nicely but if you insert to the list one more input and then try to search the app returns The second argument to foreach is not a list. The second argument is: *nothing*. thanx for your help but i have stuck with that!
test1.aia

Taifun

unread,
Jan 5, 2015, 8:55:18 AM1/5/15
to mitappinv...@googlegroups.com
your example works fine for me after adding the 2 additional items
do you test with a device or the emulator?
this seems to be a limitation of your device or the emulator, then..


.
do you really add all the data manually into the list?
let me recommend to store the data in a text file instead (each row is an item) and upload it as asset into App Inventor, read the file in Screen.Initialize using the file component and convert it into a list using the split at block, just split at \n (new line)



Taifun

Παναγιώτης Σκούρτης

unread,
Jan 5, 2015, 9:56:28 AM1/5/15
to mitappinv...@googlegroups.com
when i make the do it action the app returns me that. i try to save the apk to my computer and install it to devices and didn't start the app i will try to do it in a text file or if i made a second list can i use it with the same search button?
do it.png

Taifun

unread,
Jan 5, 2015, 10:17:48 AM1/5/15
to mitappinv...@googlegroups.com
do you test with a device or the emulator?
Taifun

Παναγιώτης Σκούρτης

unread,
Jan 5, 2015, 10:26:09 AM1/5/15
to mitappinv...@googlegroups.com
with the companion returns the message of the topic and i download it as .apk in my decices and didn't start
 

Παναγιώτης Σκούρτης

unread,
Jan 5, 2015, 12:33:12 PM1/5/15
to mitappinv...@googlegroups.com
and the file component dosen't do anything!

Taifun

unread,
Jan 5, 2015, 12:39:37 PM1/5/15
to mitappinv...@googlegroups.com
use Do it to debug your blocks, see tip 4 here 

Top 5 Tips: How to learn App Inventor

Παναγιώτης Σκούρτης

unread,
Jan 5, 2015, 12:47:31 PM1/5/15
to mitappinv...@googlegroups.com
Error from Companion: The operation length of list cannot accept the arguments: *nothing* this is the return from Do it in lenth of the list command

Παναγιώτης Σκούρτης

unread,
Jan 5, 2015, 3:29:10 PM1/5/15
to mitappinv...@googlegroups.com
for some reason reconize the list as "nothing"

Ghica

unread,
Jan 6, 2015, 8:11:36 AM1/6/15
to mitappinv...@googlegroups.com
Must be because what you think is a list is not a list and therefore has no length. Did you overwrite your list somehow, by replacing the list with an element instead of adding it for example?
Cheers, Ghica.

Παναγιώτης Σκούρτης

unread,
Jan 6, 2015, 8:35:45 AM1/6/15
to mitappinv...@googlegroups.com
as far as i know i didn't replace it with something. the problem start when i pas the 693 inputs in my list before i pas that number everything works perfect

Ghica

unread,
Jan 6, 2015, 9:09:17 AM1/6/15
to mitappinv...@googlegroups.com
It must be. Did you try Taifuns advice and make a file of your list? Did that work?

Παναγιώτης Σκούρτης

unread,
Jan 6, 2015, 9:51:07 AM1/6/15
to mitappinv...@googlegroups.com
no the file dont work do you want to sent you the .aia file to give it a look?

Ghica

unread,
Jan 6, 2015, 1:16:54 PM1/6/15
to mitappinv...@googlegroups.com
Ok. Post it here. I will look at it tomorrow.

Παναγιώτης Σκούρτης

unread,
Jan 6, 2015, 1:35:37 PM1/6/15
to mitappinv...@googlegroups.com
thanx for your help!
DustBag.aia

Ghica

unread,
Jan 6, 2015, 4:40:22 PM1/6/15
to mitappinv...@googlegroups.com
OK,
I looked at your .aia file. One of my problems is that I learned classic greek 50 years ago, but that does not help me understanding this.
One thing however is crystal clear: you cannot have a list with empty spaces. That causes all your problems. You could put empty strings there, that would make it much better.

The same question again: do you have a file which contains the text of the items you have now in the list?
The way you have built the list is really extraordinary, it must have been a lot of work, but it will cause you a lot of trouble in the future.
Now, you can do two things: either you upload the file containing the text for the list (that would be easiest), or you correct the list by making sure there are no empty entries in it, then post the .aia again, and I will make the file for you. I cannot repair the list for you, it would take me too much time.
Cheers, Ghica.

Παναγιώτης Σκούρτης

unread,
Jan 6, 2015, 5:01:57 PM1/6/15
to mitappinv...@googlegroups.com
thanx for your time but the empty entries is not the problem becouse i have the same problem and when there is no empty entries i dont have them to a text file but when i made a litle sample i didnt make it work. can you make the file component with only one entrie to be working to see it how this component work? and i will make the list from the start in the file component.

thanx again for your time

Ghica

unread,
Jan 6, 2015, 5:53:53 PM1/6/15
to mitappinv...@googlegroups.com
Yes, you are right. With a small example it works AND you can have empty entries. So, muddy instead of clear.
It must be that the blocks editor cannot handle this large list. It takes a long time to do something and it stopped every time I try to remove an entry from the list. So, I am totally stuck trying to repair your list.

Reading a file containing the data into a list of this size should however be no problem, there are apps with a lot more data than you have. And it will make you a lot more flexible when you want to change something.
Cheers, Ghica.

Παναγιώτης Σκούρτης

unread,
Jan 7, 2015, 1:01:53 AM1/7/15
to mitappinv...@googlegroups.com
Again thanks for your help! It's easy for you to make a small example with file component handler?

Ghica

unread,
Jan 7, 2015, 10:12:46 AM1/7/15
to mitappinv...@googlegroups.com
OK, Here it is.
What I did, was making a new list and adding 10 lines of the old list to it. Now I deleted the old list, which gave me some space to breathe (b.t.w. it seems that Chrome is a bit better at manipulating these large things).
Then, I saved a file to my phone, which I then uploaded. You can use this file as basis for your long list. Then I loaded the file in the media section of the app, so that you can easily read it from within the app. You have to replace it later with your real list.
The file is read at screen1.initialize, but for testing I had a button (you can remove it).

Some considerations: 
Are you going to give your app to many users? in that case you should rethink how to provide updates to them. Maybe you do not want to update the whole app frequently.
You could place the file in a TinyWebDB or a Fusion table, but that would require an internet connection now and then.
I hope this helps. Let us now when it works.
Cheers, Ghica.
bags.txt
DustBag_copy.aia

Παναγιώτης Σκούρτης

unread,
Jan 7, 2015, 4:18:52 PM1/7/15
to mitappinv...@googlegroups.com
it seems to work fine for know but i didn't rich 692 entries if i understand well i have to add the entries in the txt file and in the list in app inventor? 

Ghica

unread,
Jan 8, 2015, 4:06:27 AM1/8/15
to mitappinv...@googlegroups.com
Hi,
I should have explained better. You can delete the global bags list if you wish. I just used it to create the file. What you have to do is to add your entries to bags.txt and then upload this file into your app as if it were an image. (You should see bags.txt already now, your expanded file will replace it. So you never have to update the list in app inventor. You can also delete the save file blocks, I left them to show how I made the file, but you do not need them anymore.
Cheers, Ghica.

Παναγιώτης Σκούρτης

unread,
Jan 8, 2015, 4:11:12 AM1/8/15
to mitappinv...@googlegroups.com
Thanks I will check it the afternoon!

Παναγιώτης Σκούρτης

unread,
Jan 8, 2015, 4:07:34 PM1/8/15
to mitappinv...@googlegroups.com
Thanx for your help it works perfectly! The only problem is that the app calls notifier eather founds result in search or not but I can live and without notifier. Thanx again for your time!!!!

Ghica

unread,
Jan 8, 2015, 4:26:12 PM1/8/15
to mitappinv...@googlegroups.com
You can delete or disable the notifier in the file Reading part. It was just a check to make sure that the correct nummer of lines was read.
Reply all
Reply to author
Forward
0 new messages