Sign in to follow this  
Followers 0
MazeMiami

Script Issue please help (Loop issue)

10 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Just ran that little test and the loop is going up but why isn't the the file changing see any error i may be missing ?

I'm confused yet again

Share this post


Link to post
Share on other sites

Just ran that little test and the loop is going up but why isn't the the file changing see any error i may be missing ?

I'm confused yet again

Try a different loop eg

While $num < 178

<do stuff>

WEnd

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

It's better to use $num += 1 then $num = $num + 1

and is this an Iphone program? those directories look familiar.

Edit: woohoo 300th post. My spamming is massified

Edited by youknowwho4eva

Giggity

Share this post


Link to post
Share on other sites

works properly for me

Share this post


Link to post
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

Share this post


Link to post
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!!

Share this post


Link to post
Share on other sites

It's better to use $num += 1 then $num = $num + 1

neither way is better.

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0