[jawsscripts] Re: Time format function.
- From: "Paul Magill" <magills@xxxxxxxxxxx>
- To: <jawsscripts@xxxxxxxxxxxxx>
- Date: Sun, 30 Dec 2007 22:03:05 +1100
Hi Jeet,
There are different ways of approaching this.
The below 2 functions combine to give a result that may suit your needs.
Just pass the function SayFormattedTime, a string such as in your examples.
String Function FormatPeriod (string sPeriod) ; formats either hours or
minutes
IF (StringToInt (sPeriod) == 0) THEN
RETURN ("")
ELIF (StringToInt (sPeriod) == 1) THEN
RETURN (sPeriod + " ")
ELSE ; hours or minutes > 1
RETURN (sPeriod + "s ")
ENDIF
EndFunction
Void Function SayFormattedTime (string STime)
VAR
STRING sHours, STRING sMinutes, STRING sSeconds
LET STime = stringStripAllBlanks (STime); not required if sTime never
contains spaces
; uses StringSegment to separate hours, minutes & seconds based on the colon
IF (StringSegment (sTime, ":", 3) > "") THEN; all 3 components exist
LET SHours = FormatPeriod (StringSegment (STime, ":", 1) + " hour")
LET SMinutes = FormatPeriod (StringSegment (STime, ":", 2) + " minute")
LET sSeconds = StringSegment (sTime, ":", 3)
ELIF (StringSegment (sTime, ":", 2) > "") THEN; minutes & seconds exist
LET SMinutes = FormatPeriod (StringSegment (STime, ":", 1) + " minute")
LET sSeconds = StringSegment (sTime, ":", 2)
ELSE ; only seconds showing
LET sSeconds = StringSegment (sTime, ":", 1)
ENDIF ; how many segments in time string
; Note: the "x" is required because of the odd way Jaws compares numeric
strings
IF ("x" + sSeconds == "x00.0") THEN
LET sSeconds = "0"
ELIF (StringLeft (sSeconds, 1) == "0") THEN
LET sSeconds =stringChopLeft (sSeconds, 1)
ENDIF
LET sSeconds = sSeconds + " seconds"
SayString (sHours + sMinutes + sSeconds)
EndFunction
Regards,
Paul from Aust
----- Original Message -----
From: "Jeet" <LoveForAll@xxxxxxxxxxxxxx>
To: <jawsscripts@xxxxxxxxxxxxx>
Sent: Saturday, December 29, 2007 4:59 PM
Subject: [jawsscripts] Time format function.
Hello friends, In an audio application, I find the folowing trouble:
the time info is provided this way, and I am in need to write a script to
interprate it correctly.
For example: if a five minute's file is open, info is:
5:00.0 only a single colon sign can prove it,
1:5:00.0
the zero after a point sign is a fraction of a second.
You'd need to check for colons in the time. If there are no colons,
then the time in seconds and fractions of a second after the decimal.
If there is one colon, then it is minutes, seconds, and fraction. If
there are two colons, then it is hours, minutes, seconds, and fraction.
I need to write a function that I call via one scripts and anounce it
properly.
Please help me please!
Thank you.
--
Contact:
Direct-cell: +919213153776
Skype:
Jeet.delhi
"The Scourge Of Authoritarianism Is Intellectualism."
----------------------------------------------------------------------
Get a free email account with anti spam protection.
http://www.bluebottle.com/tag/2
__________
View the list's information and change your settings at
http://www.freelists.org/list/jawsscripts
__________
View the list's information and change your settings at
http://www.freelists.org/list/jawsscripts
- References:
- [jawsscripts] Time format function.
- From: Jeet
Other related posts:
- » [jawsscripts] Time format function.
- » [jawsscripts] Re: Time format function.
- » [jawsscripts] Re: Time format function.
- » [jawsscripts] Re: Time format function.
- » [jawsscripts] Re: Time format function.
- » [jawsscripts] Re: Time format function.
- » [jawsscripts] Re: Time format function.
- [jawsscripts] Time format function.
- From: Jeet