Problem facing in shuffling text

Hi Everyone. So I am making an application. It has quotes on it. I want the quotes to change when the user opens the application meaning I want the quotes to shuffle so I was using this as an inspiration
The shuffling is happening and the quotes are changing but along with it this when other screens close the quote changes as well. I don't want that to happen. I was using when Screen. Initialize but when I saw my problem I used when the other Screen closed but from that my quotes were not shuffling. Only the first quote was showing. Can anyone help me regarding this? Any help will be appreciated. I shall be very thankful to you.
These are my blocks for your reference.


Save the new shuffled list in TinyDB and use that one instead.

What do you mean? Can you please elaborate. I wasn't able to understand it. Sorry. The new shuffled list is a do procedure so how it be stored in a tinyDB and how can I use that. I don't get it I am really sorry but I am not getting what you are trying to say

You shuffle a list, right? The list is in the global variable Quotes.
Put the new shuffled list in a variable (or not) and save that list in a TinyDB tag. Just like you would do with a variable. Then use that list stored in TinyDB to keep the shuffling after you go back to the initial screen.

This is what I am getting from your reply
You want me to store the shuffled list which is a procedure in a variable and ultimately into the TinyDB tag. Then when my screen1 closes the shuffling would be stored in the TinyDB and the quote would be shown. This is what I am getting.
Now this is my problem
The procedure is a method and the procedure shuffle list where the list is also a procedure so the blocks won't fit . This is my problem. How can I make the blocks fit.
I do hope that you get what I am trying so say. Anyway Thanks for replying and helping me. :slight_smile:

Please explain in more detail and show screenshots of what exactly should be displayed (before and after shuffling).

switch screens correctly, see here The recommended method of switching screens in App Inventor and read chapter "Some Notes" there to find out, that you have to build the app and test it using the apk file


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

I'm not sure I got it right. But, as far as it can be seen from the blocks, only one quote should be displayed. Wouldn't the following blocks do the same?



Sorry Just saw all the messages. My problem or the thing I am stuck on is that I want to make a list of a few quotes then I want to shuffle them and display them but I only want to shuffle and display them when a specific screen i.e is Screen1 is closed and the "MainScreen" is opened on which I want to display the quotes. So when "Screen1" closes and "MainScreen" opens I want to shuffle the quotes and show them on the "MainScreen". The problem that I am facing is the otherscreen close event is not working because it is only showing one quote. It is not shuffling and only showing the top quote which I don't want. I want to shuffle the quotes and the show different quotes. I hope I was able to explain my problem. Sorry for the english. If you want I can send the aia. file. Maybe that will clear things up. Should I send the aia. file?

But you want to show only one quote at a time right? Not all the shuffled quotes.
If that's what you want, you only have to use the "Pick Random Item" block from the Lists blocks.

Also, this part of your blocks doesn't make sense: You will always see only the last item (9) in Label1 here:


1 Like

This is how I want my application to work.

  1. Login Screen
  2. User logins in
  3. Main Screen opens and this Quote shows up "Say NO to the demands of the world. Say YES to the longings of your own heart." It does not need to be the same quote.
  4. User opens another screen "Screen2"
  5. User comes back to the Main Screen.
  6. Same Quote shows up "Say NO to the demands of the world. Say YES to the longings of your own heart."
  7. User closes the app
  8. Opens the app again.
  9. logins in
  10. in the Main Screen a new Quote shows up that have been shuffled up. It could be any quote from the list.
  11. The process repeats

Then why are you shuffling the list in the "When Other screen closed" event?
That's exactly the opposite of what you explained.

You have to follow @Taifun's advice to open and close screens correctly. If you open Screen2 and then you EXIT Screen2, you just close it instead of opening again Screen1, then Screen1 should still be the same.

Again, you don't OPEN Screen1 again in Screen2. You CLOSE Screen2, to force the app to return to Screen1. That way Screen1 will be the same as it was before.

Also, have you checked what I told you about these blocks? This doesn't make sense. Only item 9 will show:


This is all you have to do regarding those quotes:
Be aware that this method only works in your compiled apk. When testing in companion, the Screen1.Initialize event will be triggered when you close a screen. That will not happen when you run your compiled app.

In Screen1 select a random quote when Screen1 Initialize and display it in the label:

In Screen2:


This is how it works:

What you are doing is right. I want this to happen but I want that when the app restarts ONLY then the quote changes. Other than that I want the quote to remain the same whether the screen changes from screen1 to screen2 or the other way around or in any way. Plus I want to shuffle the quotes so that I won't know which quote will out to be the next one.

That's exactly what my example did. Did you watch the video?

Try this: App_2.aia (45.0 KB)