login | register
Tue 02 of Dec, 2008 [15:31 UTC]

voip-info.org

Discuss [1] History

Asterisk cmd While

Created by: Corydon76,Last modification on Fri 12 of Oct, 2007 [12:15 UTC] by chandave

While

Loop until condition is false

Synopsis

While(condition)

Description

Execution loops between a While and an EndWhile statement, until the condition specified in the While evaluates to false. The condition is evaluated once per loop, at the beginning.

Example

 exten => 123,1,Answer
 exten => 123,n,Set(i=1)
 exten => 123,n,While($[${i} < 5])
 exten => 123,n,SayNumber(${i})
 exten => 123,n,Set(i=$[${i} + 1])
 exten => 123,n,EndWhile


Notes

  • While / EndWhile supports nesting. That is, you can have more than one set of While / EndWhile executing for the same channel at once.
  • If the While condition initially evaluates to false, Asterisk will jump down to after the matching EndWhile.
  • I see in the Asterisk subversion trunk there is yet another loop control modifier, ContinueWhile


Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ



Comments

Comments Filter
222

333Example - Don't forget to answer

by joss, Tuesday 02 of May, 2006 [05:38:48 UTC]
if you want the hear the SayNumber you better answer the channel first.