cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
366
Views
0
Helpful
1
Replies

UCCX Script get digits

isul97
Level 1
Level 1

Hi 

i have problem how make the user input check if 5 or less it is accepted and i use all buttons 1 to 9 and # and * so cant use something to terminate the input i use if statement inside successful  userinput.length()<=5 and still only take the input length 5 from extended get digits 

 

timeout use it for switch 

1 Reply 1

eva753kimson
Level 1
Level 1

Hello,

The core of the problem is that your get digits function, as you have it configured, is likely waiting for exactly 5 digits before it returns. Even if you put an if statement after the function call to check the length, the program won't get to that if statement until 5 digits have already been entered.

To fix this, you need to use a function or setting that allows for a variable-length input and is terminated by a timeout or a specific keypress that is not a digit. Since you're using all the other keys (* and #), the best way to handle this is by using a timeout.

You need to reconfigure or find a different version of your get digits function that has a timeout parameter. This parameter specifies how long the system should wait for a new digit after the previous one was entered.

how this would work:

Start listening for digits.

User enters a digit (e.g., '3').

The function starts a timer (e.g., 3 seconds).

If the user enters another digit (e.g., '1') within 3 seconds, the timer resets.

If the timer expires, the function returns whatever digits were collected, even if it's less than 5.

This method lets the user terminate the input simply by pausing. Your code would then look something like this:

// Assuming your function is called `get_digits_with_timeout`
// and takes a maximum length and a timeout duration.

user_input = get_digits_with_timeout(max_length=5, timeout=3)

// Now you can safely check the length of the input
// which will be 5 or less.

if (user_input.length() <= 5) {
// Input is valid, proceed
} else {
// This part of the code might not be needed if the timeout works correctly
}