05-29-2009 01:19 PM - edited 03-14-2019 04:09 AM
Hi,
I have a script which uses the Get Call Contact step to read the Calling Number of a contact and store it in a string.
The calling number is manipulated by the H.323 gateway to add the PSTN access code "9" so that users can directly return calls from their phone logs without editing the number. For example, if a caller with the number 02082363299 calls the calling number is set to 902082363299.
This causes me a problem in my script as I want to play the number as a generated prompt to the caller and do not want them to hear the initial 9.
Can anyone tell me how I can manipulate the contents of the string storing the number to strip off the initial digit?
I have thought changing the contents of the string to an integer and subtracting 900000000000 but this would also lose the second digit which would always be a zero.
I anyone can suggest how I can do this I would be most grateful.
05-29-2009 02:57 PM
Found the answer.
Assuming that the 902082363299 number is in a string called CallingNumber and the result is to be stored in ResultNumber
Use a SET step with the variable ResultNumber and value CallingNumber = CallingNumber.substring(1, CallingNumber.length())
A sample script which also generates and plays a prompt to announce the number is attached for those who want to do the same thing.
06-03-2009 12:09 AM
Thank you very much for your script, but can you tell me how i should modify this:
CallingNumber.substring(1, CallingNumber.length())
If I want to drop the last 1-2 digits not the first.
For example if i have this number 83719063095, I want to make 837190630
06-03-2009 02:10 AM
Hi,
I am not a Java expert by any means but I think the following would work.
CallingNumber.substring(0,-2)
0 is the "startIndex" and specifies the beginning index. -2 is the "endIndex" and specifies the stopping point.
0 tells the system to start from the first character (8 in your example). -2 tells the system to stop two characters from the end (0 in your example).
Let me know if this works.
06-03-2009 10:19 PM
Thanks again.
The example you mentioned CallingNumber.substring(0,-2) doesn't work, I had an error which sad that string index -2 is out of range.
Than I played with this (0,-2), and found that for my example, if I want to drop last 2 digits, it should be like this:
CallingNumber.substring(0,9)
It drops nothing from the beginning and saves only first 9 digits.
06-04-2009 01:31 AM
Hi vadimpunk,
I am glad that you managed to get the script to do what you needed.
Your solution would be fine for fixed length numbers but, if you need to do the same thing for variable length numbers, the following expression would work.
CallingNumber.substring(0, (CallingNumber.length())-2)
I have updated my script to include this. It also now uses the Get Call Contact step to read the calling number rather than just reading out the static string of the original script.
06-04-2009 02:11 AM
Hi jamesha,
Very helpful script, thanks
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide