cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2033
Views
0
Helpful
4
Replies

How to the decimal discard digits from a variable

Hi,

I'm trying to build a script calculating the waiting time. After that I want to instruct the script to play a prompt announcing that value. My problem is that I want to announce minutes and seconds. In order to do that, I thought to get the Wait Time, divide that by 60 and then calculate how many minutes and remaining seconds left in order to announce it. For example:

WaitTime = 256 (always in seconds)

WaitTimeIn Minutes = WaitTime / 60

So, WaitTimeInMinutes will be 4.3. This means that I have 4 minutes and the rest of the seconds. In order to calculate the exact remaining seconds I do:

RemainSeconds = WaitTime - (WaitTimeInMinutes * 60)

This should give me 16 seconds, if we assume that WaitTimeInSeconds is 4 and not 4.3.

My problem is how to get only the 4 from the WaitTimeInSeconds and not 4.3. I want to discard the decimal part.

Is there any other way to make this custom prompt?

Thank you in advance.

Agelos

4 Replies 4

Anthony Holloway
Cisco Employee
Cisco Employee

mm

I would like to introduce you to the modulus.

Example:

Set ewt = 65

Set min = ewt / 60

Set sec = ewt % 60

Sent from Cisco Technical Support iPhone App

Indeed.

Regards,

Geoff

Thanks alot Anthony.

I'll try this approach.

Agelos

mclenden
Level 1
Level 1

You could also use the trunc function:

trunc(WaitTime = 256 (always in seconds))

It will trim any number down to an integer.

http://www.cisco.com/en/US/products/sw/custcosw/ps1001/products_user_guide_chapter09186a00803bd137.html

Peace,

Michael Clendening