Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random word selection
#1
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]
#2
first like your grouping
Code:
Copy      Help
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
Code:
Copy      Help
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
Code:
Copy      Help
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
Code:
Copy      Help
str group="one day at a time"
ARRAY(str) a
tok(group a)
out a[RandomInt(0 a.len-1)]


Forum Jump:


Users browsing this thread: 1 Guest(s)