How to not allow repetition in what was displayed? Help me, please.

thiagojsc

New member
Hello. I'm having trouble implementing a function in this macro. I believe that for programmers it should be something very easy.

The purpose of the macro is to display a title a few times (number of views is random), choosing between 5 available titles. (Note: it was poorly implemented, but it works)

Up to this point everything is fine. I need to implement some functionality so that the same title is not repeated.

To solve this problem, I believe it is necessary to create a variable that registers the titles that have already been displayed and some conditional that controls that titles are not repeated.

Since I'm not a programmer, I'm going crazy. Please help me to solve this problem.
 

Attachments

  • CHOOSE_TITLES.macro
    7.9 KB · Views: 1
  • CHOOSE_TITLES.png
    CHOOSE_TITLES.png
    96.9 KB · Views: 9

Dm114

Well-known member
Hello. I'm having trouble implementing a function in this macro. I believe that for programmers it should be something very easy.

The purpose of the macro is to display a title a few times (number of views is random), choosing between 5 available titles. (Note: it was poorly implemented, but it works)

Up to this point everything is fine. I need to implement some functionality so that the same title is not repeated.

To solve this problem, I believe it is necessary to create a variable that registers the titles that have already been displayed and some conditional that controls that titles are not repeated.

Since I'm not a programmer, I'm going crazy. Please help me to solve this problem.
First of all, you don't need to have several Clear variable actions as this action allows you to clear several variables in one statement.

To solve your problem, I would suggest to:
- store the whole list of N title numbers from 1 to MAX) in a string variable X in this way → •1•2•3•...•MAX•
- set N to MAX
- in a loop while N>0
* get a random number I in the range of 1 to N
* play the corresponding title
* remove (Text manipulation action) •I• from the string variable
* set N to N-1

When loop ends (N=0), loop to the beginning of your macro to reset the whole list of title numbers and N to MAX.
 

Dm114

Well-known member
To set X variable with the list of numbers from 1 to MAX, use a loop if this number is high enough. Don't forget to surround the variable with a special character (such as • }.
 

thiagojsc

New member
To set X variable with the list of numbers from 1 to MAX, use a loop if this number is high enough. Don't forget to surround the variable with a special character (such as • }.

Thanks Dm114. I will study your guidelines and try to implement. If not, I'll come back and ask for help.

In this case, will the title be displayed in random sequence? For example: 5 titles will be displayed to the user in random sequence (2, 3, 1, 4 and 5)
 

Dm114

Well-known member
Thanks Dm114. I will study your guidelines and try to implement. If not, I'll come back and ask for help.

In this case, will the title be displayed in random sequence? For example: 5 titles will be displayed to the user in random sequence (2, 3, 1, 4 and 5)
I don't really understand your need? Do you mean you want to display the list in the random order prior to playing it?

In this case, it's a bit more sophisticated. I would suggest to:
1⁰) create an array with (title , filename) couples
2⁰) create a working array similar to the previous one but randomly ordered
3⁰) display this array
4⁰) play each titles from this array
 
Top