Board Thread:Questions and Answers/@comment-24973829-20140905204938/@comment-5334617-20140906051608

TriforceOfKirby wrote:

PTIME$=TIME$ IF MID$(TIME$,3,2)!=MID$(PTIME$,3,2)THEN VAR=VAR+1

Timers are tricky to do right. This code will hardly ever 'tick': it will only increment  if the clock-minute happens to change in between the first reference to   and the second reference to it. If you reverse the two statements, it will work most of the time, but not all of the time: it will not tick on those occasions when the clock-minute happens to change between the first and second reference to.

To use  correctly in this scheme, you need to initialize a variable before the action begins:

CTIME$=TIME$

In the main loop, you need to make just one reference to, and use it in two places: first, to check against the previous string, then in the next iteration, to check against the next string.

PTIME$=CTIME$:CTIME$=TIME$ IF MID$(CTIME$,3,2)!=MID$(PTIME$,3,2)THEN VAR=VAR+1

If you make two references to, there's always the chance the event you're trying to capture will happen in between those two references, and the system will malfunction in one way or another.

Of course, the big issue with this system is that the variable gets incremented when the clock-minute changes... which is not the same as one minute after the game starts, two minutes after the game starts, etc.. If the game starts near the end of a clock-minute, it will get incremented almost immediately, otherwise, there will be some delay (up to a minute) before it gets incremented.