Merge Steve Murphy's (murf) complete re-implementation of AEL, which is now no longer...
[asterisk/asterisk.git] / pbx / ael / ael-test / ael-test1 / extensions.ael
1
2 macro testdial(number, timeout) {
3     Dial(IAX2/vpconnect-t02/${number},${timeout},${OG_DIAL_FLAGS});
4     switch (${DIALSTATUS}) {
5     case CHANUNAVAIL:
6         goto dial-trunk2;
7         break;
8     default:
9         NoOp(t02 Unavailable - ${DIALSTATUS});
10         return;
11     }
12
13 dial-trunk2:
14     Dial(IAX2/vpconnect-t01/${number},${timeout},${OG_DIAL_FLAGS});
15
16 }
17
18 macro exten-gen(name,pword)
19 {
20         if( ${DB_EXISTS(org/${GroupID}/${name}/secret)} = 0 )
21                 goto other|nomatch|begin;
22         if( ${DB(org/${GroupID}/${name}/secret)}foo != ${pword}foo )
23                 goto other|nomatch|begin;
24
25 };
26
27 context what {
28         who =>
29         {
30                 random(51) NoOp(This should appear 51% of the time);
31
32                 random( 60 )
33                 {
34                         NoOp( This should appear 60% of the time );
35                 }
36                 else
37                 {
38                         random(75)
39                         {
40                                 NoOp( This should appear 30% of the time! );
41                         }
42                         else
43                         {
44                                 NoOp( This should appear 10% of the time! );
45                         }
46                 }
47         }
48 }
49
50 context other {
51         nomatch => {
52                 begin:
53                 NoOp(Hello!);
54                 switch(${DIALSTATUS})
55                 {
56                 case BUSY:
57                         NoOp(wow);
58                 case TORTURE:
59                         NoOp(woow);
60                 };
61                 NoOp(woohoo);
62         };
63 };
64
65 context testloop {
66         includes {
67                 other|16:00-23:59|m0n-fri|*|*;
68         };
69         
70     1 => {
71          for (x=0; ${x} < 3; x=${x} + 1) {
72               Verbose(x is ${x} !);
73                  if( ${x} = 1 )
74                         continue;
75                  if( ${x} = 2 )
76                         break;
77          };
78          ifTime(14:00-25:00|sat-sun|*|*) {
79                 BackGround(Hello);
80          } else
81                 BackGround(Sorry);
82          NoOp(This is a totally useless NOOP);
83     };
84     2 => {
85          y=10;
86          while (${y} >= 0) {
87               Verbose(y is ${y} !);
88                 if( ${y} = 1 )
89                         continue;
90                 if( ${y} = 2 )
91                         break;
92                 if( ${y} = 3 )
93                         return;
94               y=${y}-1;
95          };
96     }; 
97     regexten hint(nasty/Thingy) 3 => {
98         for (x=0; ${x} < 3; x=${x} + 1) 
99                 {
100                 Verbose(x is ${x} !);
101                 if( ${x} = 4 )
102                         break;
103                 if( ${x} = 5 )
104                         continue;
105                 if( ${x} = 6 )
106                         return;
107
108                 y=10;
109                 while (${y} >= 0) 
110                         {
111                                 Verbose(y is ${y} !);
112                                 if( ${y} = 4 )
113                                         break;
114                                 if( ${y} = 5 )
115                                         continue;
116                                 if( ${y} = 6 )
117                                         return;
118                                  y=${y}-1;
119                         };
120         };
121     }; 
122     4 => {
123         y=10;
124         while (${y} >= 0) 
125         {
126                 Verbose(y is ${y} !);
127                 if( ${y} = 4 )
128                         break;
129                 if( ${y} = 5 )
130                         continue;
131                 if( ${y} = 6 )
132                         return;
133                 for (x=0; ${x} < 3; x=${x} + 1) 
134                 {
135                         Verbose(x is ${x} !);
136                         if( ${x} = 4 )
137                                 break;
138                         if( ${x} = 5 )
139                                 continue;
140                         if( ${x} = 6 )
141                                 return;
142                         for (z=0; ${z} < 17; z=${z} + 1) 
143                         {
144                                 Verbose(z is ${z} !);
145                                 Verbose(z is ${z} !);
146                                 if( ${z} = 4 )
147                                         break;
148                                 if( ${z} = 5 )
149                                         continue;
150                                 if( ${z} = 6 )
151                                         return;
152                                 Verbose(z is ${z} !);
153                                 Verbose(z is ${z} !);
154                         };
155                                 
156                 };
157                 y=${y}-1;
158         };
159     }; 
160     5 => {
161                 &exten-gen(axel,brain);
162     };
163 };