Thanks:  0
Likes:  0
Dislikes:  0

1. Converting minutes to seconds

Hello,
I would like to get a hint at how to convert the minute string such as "1:34:069" into a "94.069" seconds string by using Silk.

Ringr10

2. Re: Converting minutes to seconds

Below is some code to get you started. I don't think it is exatly what you want, but it might work as a starting point.

------------------
David Genrich
david@e2Open.com
david_kim@usa.net

3. Re: Converting minutes to seconds

Here is the function I use:

[+] STRING ConvertMinToSec(STRING sTime) //Modifies the minute:second.miliseconds fomat to seconds.milliseconds
[ ] //************************************************** *************************************
[ ] //* This function converts the format Minutes:Seconds.Miiliseconds (3:15.222) to seconds
[ ] //* (195.222). In this format the value can be saved as a numeric.
[ ] //* This function requires:
[ ] //* STRING for a returned value
[ ] //* STRING sTime for the original value
[ ] //************************************************** **************************************
[ ] INTEGER iPos
[ ] STRING sTPart
[ ] NUMBER nTPart
[ ] INTEGER iLen
[ ] NUMBER nSPart
[ ] STRING sNTime
[ ]
[ ] iPos = StrPos (":", sTime) //Find the position of :
[+] if iPos != 0 //If there is a : in the string
[ ] sTPart = Left(sTime, (iPos - 1)) //Set the minutes to sTPart
[ ] iLen = Len(sTime) //Get the length of sTime
[ ] sTime = Right (sTime, (iLen - iPos)) //Cut the minutes and the : from the front of the original line
[ ]
[ ] nTPart = Val(sTPart) //Get the value of the minute string
[ ] nTPart = nTPart * 60 //Multiply the minutes by 60 (to get total seconds)
[ ]
[ ] iPos = StrPos (".", sTime) //Get the position of the period
[ ] sTPart = Left(sTime, (iPos - 1)) //Set sTPart to the seconds in the original string
[ ] iLen = Len(sTime) //Get the legth of sTime
[ ] sTime = Right (sTime, (iPos + 1)) //Cut off the seconds, but not the period
[ ]
[ ] nSPart = Val(sTPart) //Get the value of the seconds
[ ] nTPart = nTPart + nSPart //Add the converted minutes value to the seconds value
[ ] sTPart = Str(nTPart) //Get the string equivilent of the total seconds
[ ] sNTime = sTPart + sTime //Concatenate the new string with the milliseconds
[+] else //If there are no :'s in the string
[ ] sNTime = sTime //Set sNTime = to the passed in time
[ ]
[ ] return sNTime //Return the new time string
[ ]

MikeF

------------------

[This message has been edited by MikeF (edited 10-22-2001).]

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
Search Engine Optimisation provided by DragonByte SEO v2.0.40 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.