Topic: String functions

Currently, the functions available on Strings are limited. I would like to be able to do a replace on parts of a string or search a string for a particular substring or character at a specific position.

This may be a separate issue, but when calling from Quickfuse, I noticed that if I dial out to a number there is a 1 before the number in the ANI data. If I call into a Voice Application with a phone # assigned, there is not a 1 in the front of the phone number.

Re: String functions

Hi Tom,

Regarding your initial question, we have mentioned your requests in our internal feature request page. However, if you would like to do a replace on parts of a string, you can use two Substring modules and a Concatenate module to achieve this task.

In the first Substring module, you can create a substring of the first part of your string that you would like to keep. Similarly, in the second Substring module, you can create a substring of the other part of your string that you would like to keep. From here, you could use a Concatenate module to join the first substring, followed by the string entry you would like to add in, followed by the second substring.

Regarding your second question, we have been able to reproduce the behavior you have described. We are currently checking with our development team on this issue and will let you know what we find out.

Regards,
The QuickFuse Team

Re: String functions

Hi Tom,

Regarding your question on why a "1" is prepended to the ANI when calling yourself from within QuickFuse and why a "1" is not added when calling into an application with a phone number assigned, this is due to how the PSTN system works and how the number is given to us by the carrier.

For outbound calls, a 1 is required for dialing out. Thus, we prepend a 1 to the beginning of the 10-digit number that's entered (in order for these calls to go out) and this is why you see the "1" in the ANI of the Call Properties module.

However, for inbound calls, most carriers do not include the 1 in the ANI when the call is sent to its endpoint. This is why you don't see a 1 in the ANI of the Call Properties module for inbound calls.

We would consider reformatting the ANI automatically, but we're hesitant to alter data provided by the telco in case the developer needs it in an unaltered format.

Regards,
The QuickFuse Team

Re: String functions

I am also needing more string functions as Tom requested.  The substring solution does work if you already know what the string is going to be, but how to you take a part of a string up until the first decimal (for example), if you don't know what format or length the data value is already.

Basically what I need is very simple, I need to be able to format a string so that it has 2 digits after the decimal.  We are adding an amount and a service fee together and the total is appearing like 3.5 for example when i need it to be 3.50.    Any ideas how to achieve this?   We don't always know what the amount is going to be, so that's the problem.

The javascript function 'toFixed' would be awesome, but also it could be done if there was an 'indexOf' function.

Last edited by mhopkins@○●○●○ (2013-02-03 23:38:01)

Re: String functions

Hi,

While you cannot use toFixed(), you can use the Substring and Evalulate Math modules to achieve the same effect. First, use the Evaluate Math module to handle amounts with more than 2 digits after the decimal.

For example, if you had service_fee = 3.511, enter this into the Evaluate Math module:

=ceil(service_fee * 100) / 100

This will return "3.52" assuming you always want to round up. You can use floor() to always round down, or round() to round up or down depending on the digit.

Then, you can use the Substring module to make sure the substring after the period character has a length of 2. You can concatenate the appropriate number of zeros otherwise.

Regards,
The QuickFuse Team