Difference between revisions of "LOOP/ENDLOOP"
From Zenitel Wiki
(9 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{AI}} | ||
The '''LOOP''' and '''ENDLOOP''' statements are used in the [[Event Handler]]. | The '''LOOP''' and '''ENDLOOP''' statements are used in the [[Event Handler]]. | ||
The LOOP - ENDLOOP statements can not be nested. When the script execution reaches ENDLOOP, the script jumps back to the previous LOOP statement. | The LOOP - ENDLOOP statements can not be nested. When the script execution reaches ENDLOOP, the script jumps back to the previous LOOP statement. | ||
Line 4: | Line 5: | ||
[[IF/ENDIF]] along with [[STOP]] or [[BREAK (Event action)|BREAK ]] must be used to exit from the loop. | [[IF/ENDIF]] along with [[STOP]] or [[BREAK (Event action)|BREAK ]] must be used to exit from the loop. | ||
− | As a safety precaution, looping will stop after 1000 iterations | + | {{note|Use LOOP with caution. As a safety precaution, looping will stop after 1000 iterations. Don't send more than a few dozen Data protocol messages from a single event. }} |
This feature is new in AMC 11.00. | This feature is new in AMC 11.00. | ||
Line 11: | Line 12: | ||
==Useless example== | ==Useless example== | ||
+ | Uses [[Tmp_statement|tmp]], [[%tmp]] and [[%op]] to control the loop. | ||
tmp 0 "0" | tmp 0 "0" | ||
LOOP | LOOP | ||
− | $put 8 "loop %tmp(0) \n" | + | $[[PUT STRING|put]] 8 "loop %tmp(0) \n" |
tmp 0 "%op(%tmp(0),+,1)" | tmp 0 "%op(%tmp(0),+,1)" | ||
IF %op(%tmp(0),=,5) | IF %op(%tmp(0),=,5) | ||
Line 21: | Line 23: | ||
ENDLOOP | ENDLOOP | ||
$put 8 "end loop %tmp(0) \n" | $put 8 "end loop %tmp(0) \n" | ||
+ | |||
The script prints the following text on [[TST]]: | The script prints the following text on [[TST]]: | ||
loop 0 | loop 0 | ||
Line 29: | Line 32: | ||
end loop 5 | end loop 5 | ||
− | ==Useful | + | ==Useful examples:== |
− | This example switches | + | This example switches off [[Audio Program]] on own station plus stations in [[Mutual exclusion group]] of own station, using [[TPROG]] and [[%ges]]. |
$TPROG L%1.dir U%chg(0,1) | $TPROG L%1.dir U%chg(0,1) | ||
Line 41: | Line 44: | ||
tmp 0 "%ges(%1.phy, %tmp(0))" | tmp 0 "%ges(%1.phy, %tmp(0))" | ||
ENDLOOP | ENDLOOP | ||
+ | |||
+ | |||
+ | |||
+ | Another example her: [[Group Call - Increased volume]] | ||
[[Category:Event Handler]] | [[Category:Event Handler]] | ||
[[Category:Built-In Action Commands]] | [[Category:Built-In Action Commands]] |
Latest revision as of 11:11, 19 December 2022
The LOOP and ENDLOOP statements are used in the Event Handler. The LOOP - ENDLOOP statements can not be nested. When the script execution reaches ENDLOOP, the script jumps back to the previous LOOP statement.
IF/ENDIF along with STOP or BREAK must be used to exit from the loop.
Use LOOP with caution. As a safety precaution, looping will stop after 1000 iterations. Don't send more than a few dozen Data protocol messages from a single event. |
This feature is new in AMC 11.00.
Examples
Useless example
Uses tmp, %tmp and %op to control the loop.
tmp 0 "0" LOOP $put 8 "loop %tmp(0) \n" tmp 0 "%op(%tmp(0),+,1)" IF %op(%tmp(0),=,5) BREAK ENDIF ENDLOOP $put 8 "end loop %tmp(0) \n"
The script prints the following text on TST:
loop 0 loop 1 loop 2 loop 3 loop 4 end loop 5
Useful examples:
This example switches off Audio Program on own station plus stations in Mutual exclusion group of own station, using TPROG and %ges.
$TPROG L%1.dir U%chg(0,1) tmp 0 "%ges(%1.phy, 0)" LOOP IF %op(%tmp(0),=,0) STOP ENDIF $TPROG N%tmp(0) U%chg(0,1) tmp 0 "%ges(%1.phy, %tmp(0))" ENDLOOP
Another example her: Group Call - Increased volume