Jump to content

Script Issue please help (Loop issue)


 Share

Recommended Posts

For Some Reason $num wont loop like the rest it should increase by one number on each loop here is what i have

$num = 1
$FileF = "Female_"&$num&".wav "
$FileM = "male_"&$num&"m.wav" 
$extF = 3003
$extM = 3004

Do

Send("cp /root/voice/female/"&$FileF&" /var/spool/asterisk/voicemail/default/"&$extF&"/unavail.wav{enter}")

Send("cd /var/spool/asterisk/voicemail/default/"&$extF&"/ {enter}")

send("sox -t wav unavail.wav -r 8000 -c1 -t gsm unavail.gsm resample -ql {enter}") 

Send("cd /var/spool/asterisk/voicemail/default/"&$extF&"/ {enter}")

send("rm unavail.wav {enter}")

send("y {enter}")

$extF = $extF + 2 
$num = $num + 1

Until $num = 177
Edited by MazeMiami
Link to comment
Share on other sites

For Some Reason $num wont loop like the rest it should increase by one number on each loop here is what i have

$num = 1
$FileF = "Female_"&$num&".wav "
$FileM = "male_"&$num&"m.wav" 
$extF = 3003
$extM = 3004

Do

Send("cp /root/voice/female/"&$FileF&" /var/spool/asterisk/voicemail/default/"&$extF&"/unavail.wav{enter}")

Send("cd /var/spool/asterisk/voicemail/default/"&$extF&"/ {enter}")

send("sox -t wav unavail.wav -r 8000 -c1 -t gsm unavail.gsm resample -ql {enter}") 

Send("cd /var/spool/asterisk/voicemail/default/"&$extF&"/ {enter}")

send("rm unavail.wav {enter}")

send("y {enter}")

$extF = $extF + 2 
$num = $num + 1

Until $num = 177
Looks as if it should work. A common debugging technique is to add something like this:

msgbox(0,"",$num)

to the end of but inside the loop so oyu can check what's happening to that variable (or any otehr variable). That should help you determine what the problem is.

Link to comment
Share on other sites

You have to reset your male/female file variables every time the $num variable changes. So:

$num = 1
$FileF = "Female_" & $num & ".wav "
$FileM = "male_" & $num & "m.wav"
$extF = 3003
$extM = 3004

Do
    Send("cp /root/voice/female/" & $FileF & " /var/spool/asterisk/voicemail/default/"&$extF&"/unavail.wav{enter}")
    Send("cd /var/spool/asterisk/voicemail/default/" & $extF & "/ {enter}")
    send("sox -t wav unavail.wav -r 8000 -c1 -t gsm unavail.gsm resample -ql {enter}")
    Send("cd /var/spool/asterisk/voicemail/default/" & $extF & "/ {enter}")
    send("rm unavail.wav {enter}")
    send("y {enter}")

    $extF = $extF + 2
    $num = $num + 1
    $FileF = "Female_" & $num & ".wav"
    $FileM = "male_" & $num & "m.wav"
Until $num = 177
Link to comment
Share on other sites

Nice thanks a lot works !

Now would you mind explaining why i have to do that for this and not the other strings ?

Thanks Again!!

What do you mean not for the other strings? What other strings are you talking about?

Using a variable within a variable is not a persistent/dynamic process, its static. Meaning that once you set a variable it does not change even if the variable within it does.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...