Deleting data entries in a label

In an app I'm making, text is displayed using a label, and each new entry is added below the last by joining the pre-existing label text with "\n" and then the new text. I want to be able to only show the most recent 18 entries, and delete the oldest entry as the 18th comes in. I tried the method I came up with, but it was deleting the most recent entry instead of the oldest one. I was splitting the text into a list just for the purpose of detecting when the entries were above 18, then using a segment to extract text after the first line break.
This is the code:
Screenshot 2020-10-19 at 6.23.55 PM Screenshot 2020-10-19 at 6.22.22 PM
Any suggestions?

to remove the last item of the list, use length of list(outputEntries) as index in the remove list item block
http://ai2.appinventor.mit.edu/reference/blocks/lists.html#lengthoflist

Taifun


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

Yes, and I did that just for the sake of completion, but how do I put it back into a label? Can labels interpret lists?

you could first convert the list into a csv row using the list to csv row block and after that use the replace all block from the text drawer to replace , by \n (assuming there are no commas inside the list items itself...)

Taifun

Thanks, it worked! I just also had to replace the " with blank text boxes

1 Like

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