The routine runs every 1000 ms using a timer. Variable [P1TimeE] = Player 1 Time elapsed in secs. (i.e. this not the variable that stores the elapsed time in ms but a variable that increments by one every 1000ms)

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

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: Select all
`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 "trunc([P1TimeE]/3600)" "-1" "[P1Hrs]"

Math "trunc([P1Hrs]*3600)" "-1" "[P1secsinHrs]"

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

Math "trunc([P1TimeE]-[P1secsinHrs])" "-1" "[P1TimeRem]"

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

Math "trunc([P1TimeRem]/60)" "-1" "[P1Mins]"

Math "trunc([P1Mins]*60)" "-1" "[P1secsinMins]"

.get remainder secs

Math "trunc([P1TimeRem]-[P1secsinMins])" "-1" "[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]"