Posts: 2
Threads: 2
Joined: Apr 2018
Is there a way to set it up to select randomly from a list of words?
For example how would you write it to randomly select 1 word from the group [one, day, at, a, time]
Posts: 1,338
Threads: 61
Joined: Jul 2006
10-30-2020, 05:38 AM
(This post was last modified: 10-30-2020, 05:40 AM by Kevin.)
first like your grouping
str group="one,day,at,a,time"
ARRAY(str) a
tok(group a -1 ",")
out a[RandomInt(0 a.len-1)]
another way words as multiline string
str group=
;one
;day
;at
;a
;time
ARRAY(str) a=group
out a[RandomInt(0 a.len-1)]
another way store words in an array
ARRAY(str) a="one[]day[]at[]a[]time"
out a[RandomInt(0 a.len-1)]
or another way
with just spaces in-between the words
str group="one day at a time"
ARRAY(str) a
tok(group a)
out a[RandomInt(0 a.len-1)]