ResetTimer to negative values?

Find quick help here to get you started with Hollywood
Post Reply
Flinx
Posts: 3
Joined: Sun Feb 14, 2021 9:54 am

ResetTimer to negative values?

Post by Flinx »

Hello all,

Is it permissible to set a timer to negative values? I didn't find a hint in the manual, so I tried. It seemed to work, and there was also an overflow at 2^32-1 (tested under Windows). But in practice there are strange effects when starting with certain values. With full seconds it works. But with values between full seconds it doesn't. GetTimer() returns alternately correct and incorrect values at one-second intervals.
Here is the output of GetTimer() in 100ms intervals for four time values:

Code: Select all

StartTimer(1)
offset=(-500)
ResetTimer(1, offset)
For i=1 To 18
	DebugPrint(GetTimer(1))
	Wait(100,#MILLISECONDS)
Next

Code: Select all

-1000	-800	-500	-200
-914	-710	-405	-101
-814	4294357	-304	-1
-714	4294457	-204	99
-614	4294557	-104	199
-514	4294657	4294963	299
-414	4294757	4295063	4295366
-314	4294857	4295163	4295466
-214	4294957	4295263	599
-114	4295057	4295363	699
-14	190	496	799
86	290	596	899
186	4295357	696	999
286	4295457	796	1099
386	4295557	896	1199
488	4295660	4295963	1302
590	4295761	4296063	4296370
691	4295862	4296163	4296471
What am I doing wrong?

Ralf

User avatar
msu
Posts: 63
Joined: Mon Jun 13, 2016 11:36 am
Location: Sinzig/Germany

Re: ResetTimer to negative values?

Post by msu »

Hello Ralf,
first of all, welcome to the forum. :)
Flinx wrote:
Sun Feb 14, 2021 1:52 pm
Is it permissible to set a timer to negative values?
ResetTimer says the following:
You can use this function to reset an existing timer to zero or to a specified time. If you want to reset the timer to zero, simply leave out the second argument. Otherwise use the second argument to specify a time in milliseconds for the timer.
I honestly don't understand what you need negative numbers for in the timer?

If it is just a matter of correcting the timer (pure speculation), you could do it like this:

Code: Select all

StartTimer(1)
offset=500
For i=1 To 18
	DebugPrint(GetTimer(1)-offset)
	Wait(100,#MILLISECONDS)
Next

User avatar
airsoftsoftwair
Posts: 4505
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ResetTimer to negative values?

Post by airsoftsoftwair »

I also don't see why anyone would want to use negative values with the timer functions... they were definitely not designed for that. But if you explain why you need this, I might consider implementing it ;)

Flinx
Posts: 3
Joined: Sun Feb 14, 2021 9:54 am

Re: ResetTimer to negative values?

Post by Flinx »

Hello,

and thank you, but no really need to implement. I have a solution in the meantime, but I thought I should ask, because if negative values are possible, someone else would try to use it too. If it seems to work at first sight...
I'm writing on a lyrics viewer, and there I have to read an offset from a text file. The first idea was to add this offset to the timer. Of course it can be done in another way.

Ralf

User avatar
airsoftsoftwair
Posts: 4505
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: ResetTimer to negative values?

Post by airsoftsoftwair »

Flinx wrote:
Mon Feb 15, 2021 12:58 pm
and thank you, but no really need to implement. I have a solution in the meantime, but I thought I should ask, because if negative values are possible, someone else would try to use it too. If it seems to work at first sight...
Yes, that's right. It should error out on negative values and will do so now:

Code: Select all

- Fix: ResetTimer() will no longer accept negative values

Post Reply