Simple for loop, loops once


#1

I have simple FOR loop in my ael dialplan. The problem is that I have 2 files in the folder but the loop runs only once.

This is the loop

NumberOfMessages = 2;
for(LOOPCOUNT=1; LOOPCOUNT < NumberOfMessages; LOOPCOUNT++) {     
     Playback(/var/spool/asterisk/messages/${CALLERID(num)}/file${LOOPCOUNT});
}

In CLI > dialplan show I see one empty step

1. MSet(LOOPCOUNT=$[1])                       [pbx_ael]
2. GotoIf($[ LOOPCOUNT < NumberOfMessages]?3:5) [pbx_ael]
3. Playback(/var/spool/asterisk/voicemessages/${CALLERID(num)}/file${LOOPCOUNT}) [pbx_ael]
4. ()                                        [pbx_ael]
5. NoOp(Finish for_if_internal_349_350)      [pbx_ael]

And this empty step is the problem according to the output

-- Executing [Voice@internal:1] MSet("SIP/1001-00000060", "LOOPCOUNT=1") in new stack
-- Executing [Voice@internal:2] GotoIf("SIP/1001-00000060", "1?3:5") in new stack
-- Goto (internal,Voice,3)
-- Executing [Voice@internal:3] Playback("SIP/1001-00000060", "/var/spool/asterisk/voicemessages/1001/file1") in new stack
-- <SIP/1001-00000060> Playing '/var/spool/asterisk/voicemessages/1001/file1.slin' (language 'en')
[Jul 10 17:08:57] WARNING[40032][C-00000061]: pbx.c:2903 pbx_extension_helper: No application '' for extension (internal, Voice, 5)
  == Spawn extension (internal, Voice, 5) exited non-zero on 'SIP/1001-00000060'

What can be the problem? From where is coming this empty step (4. () )?


#2

LOOPCOUNT < NumberOfMessages; ? may be LOOPCOUNT <= NumberOfMessages
(or whatever the exact syntax is)


#3

Thanks but still the same output. The problem is in this empty step in dialplan after the loop.