Graphics

 View Only
  • 1.  converting seconds to a 'minutes and seconds' timer

    Posted 04-21-2015 05:40
    I have a sports feed that only provides a "seconds" game timer feed. eg 1798 seconds.

    Is there a suggestion on how I can convert this feed to a "minute and second" game timer?

    Any help would be most appreciated.


  • 2.  RE: converting seconds to a 'minutes and seconds' timer

    Posted 04-21-2015 13:40
    Hi Scott,

    You can use Visual Logic to divide your seconds value by 60 then replace the decimal with a colon. This will give you minutes and seconds.

    below is a link to a project with an example.

    https://ross.brickftp.com/f/79a828c05

    Andrew

    #XPression


  • 3.  RE: converting seconds to a 'minutes and seconds' timer

    Posted 04-21-2015 13:48

    There are probably other ways but you could let your seconds value land in a text field, which you hide and then convert the value using a script like this:



    'define variables

    dim intSec as integer

    dim min as double

    dim sec as double

    dim txt1 as xptextobject

    dim txt2 as xptextobject

    'find the text object that contains the seconds value

    if self.getobjectbyname("text1", txt1) then

    'insert the value after conversion in the intsec variable

    intsec=cint(txt1.text)

    end if

    'find the number of minutes

    min = math.round(intsec/60)

    'find the remaining seconds

    sec = math.round(intsec-(min*60))

    'return the value to text object 2

    if self.getobjectbyname("text2", txt2) then

    'check if a leading zero is reqired on the seconds

    if sec

    #XPression


  • 4.  RE: converting seconds to a 'minutes and seconds' timer

    Posted 04-22-2015 07:36
    Hi guys, thanks for the suggestions. I have tried the logic version quickly, I just need to work out a way to convert the remaining seconds to convert to parts of a minute ie 59 not 97, but I'm sure it will work out.

    Niels, I am in the stages of trying the scripting version, as I am average at scripting, I tried Andrew's suggestion first.

    Again, thank you for your knowledge.

    Cheers

    Scott

    #XPression


  • 5.  RE: converting seconds to a 'minutes and seconds' timer

    Posted 04-22-2015 21:19
    Hi Scott,

    The VL actually needs to be more complicated than what Andrew posted as that example didn't properly convert the seconds value. This will only work in 5.9 versions as the FormatFloat block does not exist in 5.7.

    The formatfloat block is being used to remove the ".000" that gets added when converting the decimal value to a string. The selector and stringlength blocks are used to determine if a leading zero needs to be added to the seconds value.



    #XPression


  • 6.  RE: converting seconds to a 'minutes and seconds' timer

    Posted 04-22-2015 21:21
    Here is the example project from my post above.. Note you need 5.9 to load this properly:

    https://ross.brickftp.com/f/9b9af3be2

    #XPression


  • 7.  RE: converting seconds to a 'minutes and seconds' timer

    Posted 04-27-2015 01:49
    Hi Brian,

    unfortunately the VL you provided doesn't work.

    Even tried loading the project you provided.

    If the seconds is changed, it has no effect on an of the other outputs.

    Am I missing something?

    #XPression


  • 8.  RE: converting seconds to a 'minutes and seconds' timer

    Posted 04-27-2015 01:56
    My apologies Bryan,

    I shut my computer down, restarted, kicked it twice, and all of a sudden everything seems to work.

    Cheers

    #XPression


  • 9.  RE: converting seconds to a 'minutes and seconds' timer

    Posted 04-27-2015 14:36
    "Percussive and Concussive Maintence" - some people even require this regularly.

    #XPression


  • 10.  RE: converting seconds to a 'minutes and seconds' timer

    Posted 04-27-2015 16:06
    The most common cause of VL not appearing to run, is that you do not have the Viewport "Active".. You need to click the blue diamond to make the viewport "active" for VL and continuous animations and other effects to be visible in the viewport.

    #XPression