HD Software Co. Blog

Software You Can Use

NeoBook Action Commands :: Elapsed time 00:00:00 – timer calculation error

Posted by Wrangler on April 29, 2012
Posted in: NeoSoft Forum. Tagged: 000000, Action, calculation, Commands, Elapsed, Error, neobook, time, timer.

Author: RickOShay
Subject: Elapsed time 00:00:00 – timer calculation error
Posted: Sun Apr 29, 2012 8:24 am (GMT -7)
Topic Replies: 0

I have a simple subroutine that calculates the elapsed time in Hours Minutes and Seconds.

The routine runs every 1000 ms using a timer. Variable [P1TimeE] = Player 1 Time elapsed.

A similar routine used to work in the previous version of Neobook – now I get weird problems.

I saw somewhere that the Maths calc has changed in 5.7.1

So what am I doing wrong? I’ve tried many different methods and each time I get the wrong result.


Code:
Math "[P1TimeE]+1" "0" "[P1TimeE]"

. convert elapsed time into hours, minutes & seconds for display

. take total elapsed seconds and divide by # secs in an hour to get hrs

Math "[P1TimeE]/3600" "0" "[P1Hrs]"

Math "[P1Hrs]*3600" "0" "[P1secsinHrs]"

.take seconds in elapsed hours and subtract from total elapsed time

Math "[P1TimeE]-[P1secsinHrs]" "0" "[P1TimeRem]"

.take remainder and divide by secs in hour to get mins

Math "[P1TimeRem]/60" "0" "[P1Mins]"

Math "[P1Mins]*60" "0" "[P1secsinMins]"

.get remainder secs

Math "[P1TimeRem]-[P1secsinMins]" "0" "[P1Secs]"

.change display in case secs = 60

If "[P1Secs]" "=" "60"

Setvar "[P1Mins]" "1+[P1Mins]"

Endif

[b].add extra zero in display[/b]

If "[P1Secs]" "<" "10"

Setvar "[P1Secs]" "0[P1secs]"

Endif

. change mins and hrs in case mins = 1 hr

If "[P1Mins]" "=" "60"

Setvar "[P1Mins]" "00"

Setvar "[P1Hrs]" "1+[P1Hrs]"

Endif

.add extra zero in display

If "[P1Mins]" "<" "10"

Setvar "[P1Mins]" "0[P1mins]"

Endif

.add extra zero in display

If "[P1Hrs]" "=" "0"

Setvar "[P1Hrs]" "00"

Endif

.output string

SetVar "[P1TimeElapsed]" "[P1Hrs]:[P1Mins]:[P1Secs]"



_________________
There’s no place like 127.0.0.1

http://www.haltech.net

NeoSoft Support Forum





Share

Posts navigation

← The GeekDads Episode #113: The Avengers Is Not a Failure (GeekDad Weekly Rewind)
The Avengers’ Hawkeye: Not Such a Bad Archer After All (GeekDad Weekly Rewind) →
  • Search

  • Categories

    • Computer HowTo Videos
    • Computer Stuff
    • Feed Generators
    • Freeware
    • Home/Hobby Software
    • Internet Software
    • NeoBook RAD5
      • NeoBook Plugins
      • NeoBook Sample Pubs
      • NeoBook Tips
    • NeoSoft Forum
    • Programming
    • Quote Of The Day
    • Uncategorized
    • Web Developer News
    • Windows Tips & Tricks
      • IE 9 Tips
    • Wired
    • WordPress Tips
  • Code Cloud

    Game Functions Java Suggestions apps Français iPad Over Jan. This 2012 Future developers software twitter podcast first Could Text More Space JavaScript About android Internet Español Facebook Apple Commands Into Data Windows NeoBookDBPro Action cloud microsoft Video From plugin google GoogleaDay General Puzzle Discussions neobook


Proudly powered by WordPress Theme: Parament by Automattic.