Help on reconfigure Dialplan

[b]It has bin almost 1 year ago I configured this script and it needs some reconfigure now.
Becasue I dont work with this system on daily basis, I hope some Guru can help me out here.

The script is simple: It calls out to some user and asking for a pincode.
If they can confirm this by pressing any digit, the call will then hangup and don’t call the next one.
If they not confirm (by not pressing any digit), the system will call the next user.

[/b]
Question 1:
I want the users to have more time to enter their digits, not in between but before they start enter digits. Where should configure the, in the ‘wait parameter’?

Question 2:
When the user press any key. (for example only 1).
It will confirm and not call the next user and hanged up.
So it seems this line: exten => s,2,Set(TIMEOUT(digit)=4) never worked, because I was expected it will wait on 4 digits (minimal) before it confirms, and when they only enter 1 digit and w8 it should call the next one.

=======================

exten => s,1,Set(nextfile=tmp02)
exten => s,2,Set(TIMEOUT(digit)=4)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,Set(stepcount=0)
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n(begin),Background(/home/administrator/sounds/alarm)
exten => s,n(prompt),Background(/home/administrator/sounds/pincode)
exten => s,n,Set(stepcount=$[${stepcount}+1])
exten => s,n,GotoIf($[${stepcount} > 2]?callnext)
exten => s,n,WaitExten(2)
exten => s,n,Goto(s,prompt)
exten => s,n(callnext),System(cp /var/spool/asterisk/${nextfile} /var/spool/asterisk/outgoing)
exten => s,n,Hangup
exten => 1,1,Goto(s,begin)
exten => 2,1,Goto(msgack,s,1)
exten => t,1,Playback(vm-goodbye)
exten => t,2,Hangup
exten => h,2,Hangup
exten => h,1 (callnext),System(cp /var/spool/asterisk/${nextfile} /var/spool/asterisk/outgoing)

tmp02 .call file:
Channel: SIP/mysipprovider-out/xxxnumbersecondengineerxxx
MaxRetries:3
RetryTime:2
WaitTime:40
Context: outboundmsg2
extension:s
Priority: 1

[outboundmsg2]
exten => s,1,Set(nextfile=tmp03)
exten => s,2,Set(TIMEOUT(digit)=4)
exten => s,n,Set(TIMEOUT(response)=10)
exten => s,n,Set(stepcount=0)
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n(begin),Background(/home/administrator/sounds/alarm)
exten => s,n(prompt),Background(/home/administrator/sounds/pincode)
exten => s,n,Set(stepcount=$[${stepcount}+1])
exten => s,n,GotoIf($[${stepcount} > 2]?callnext)
exten => s,n,WaitExten(2)
exten => s,n,Goto(s,prompt)
exten => s,n(callnext),System(cp /var/spool/asterisk/${nextfile} /var/spool/asterisk/outgoing)
exten => s,n,Hangup
exten => 1,1,Goto(s,begin)
exten => 2,1,Goto(msgack,s,1)
exten => t,1,Playback(vm-goodbye)
exten => t,2,Hangup
exten => h,2,Hangup
exten => h,1 (callnext),System(cp /var/spool/asterisk/${nextfile} /var/spool/asterisk/outgoing)

tmp03 .call file:
blabla

Hello.

Yes, in your case you may add some extra seconds into Wait() application.

But maybe it’s better to use the Read application.
As you can see, it is able to limit the maximum length of user input, but not the minimal.

I think you may check the minimal length with FUNC_LEN.

Something like:

... exten => n,Read(USRINPUT,file-to-play,4,,4) exten => n,GotoIf("${LEN(USRINPUT)}"=1?x:y) ...