Posted By
|
Message
|
Avantar1975
Registered 01/12/2011
Points 39
|
17th December, 2011 at 09:05:08 -
Hey! Hope someone can help...
If I have a text file loaded in a Rich Edit object that reads: (as an example)
Apples are nice. Apples are good. Apples are great.
How can I have only one sentance like: Apples are nice/great/good and have nice/great/good be selected at random?
So, in the program, I would either see: Apples are nice. OR Apples are great. OR Apples are good at random.
Thank you in advance!
n/a
|
Sketchy Cornwall UK
Registered 06/11/2004
Points 1971
|
17th December, 2011 at 12:09:10 -
The easiest way would be to use a List object (untick "1-based index").
If you put each word/phrase on a new line, you can just pick a random line to display:
DisplayText = List Line Text$( "List", Random(List Nb Lines( "List" )))
Alternatively, you can add delimiters (characters which define the start/end of substrings or "tokens" within a longer string), and use one of the many tokenizing extensions:
MyString = "Apples are nice.|Apples are good.|Apples are great."
DisplayText = GetToken$( "Quick Token Object", MyString, "|",Random(GetNumberToken( "Quick Token Object", MyString, "|")))
n/a
|
Avantar1975
Registered 01/12/2011
Points 39
|
17th December, 2011 at 17:45:38 -
Thank you so much 4 the help and examples. I will swot delimiters and tokens a bit.
I believe String Parser2 and Regex Object can do the same?
n/a
|
|
|