RAND(min,max)
(beginning Asterisk 1.4)
Returns a randomly-generated number between min and
max inclusive. The default for min is 0, for
max the default is the largest integer supported by the
system (usually 2147483647).
; Choose a random number between 1 and 10 (inclusive):
exten => 123,1,Set(coincidence=${RAND(1,10)})
; Game of chance:
exten => 123,1,GotoIf($[${RAND(0,100)} < 25]?won:lost)
exten => won,1,Playback(won)
exten => won,n,Goto(123,1)
exten => lost,1,Playback(lost)
exten => lost,n,Goto(123,1)
|
|
|
If you are using versions prior to Asterisk 1.4, use the
application |
|
|
|
Internal help for this application in Asterisk 1.4: -= Info about function 'RAND' =-
[Syntax]
RAND([min][|max])
[Synopsis]
Choose a random number in a range
[Description]
Choose a random number between min and max. Min defaults to 0, if not
specified, while max defaults to RAND_MAX (2147483647 on many systems).
Example: Set(junky=${RAND(1|8)});
Sets junky to a random number between 1 and 8, inclusive.
diff output to internal help in Asterisk 1.2: -- not available in Version 1.2 -- |
See also.
the section called “Random()”