timer

GFA BASIC-related articles in here please

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

sashapont
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 148
Joined: Sat Jun 03, 2017 9:40 pm

timer

Postby sashapont » Thu Jan 17, 2019 7:34 am

I have ode

Code: Select all

IF a<2
a=a+1
else
a=0
ENDIF
Print a


How I can create timer for endless repeat it after one second?
Atari Falcon, Firebee

vido
Atari Super Hero
Atari Super Hero
Posts: 694
Joined: Mon Jan 31, 2011 7:39 pm

Re: timer

Postby vido » Thu Jan 17, 2019 8:21 am

You would like to increase "a" every second while the other code is running?

sashapont
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 148
Joined: Sat Jun 03, 2017 9:40 pm

Re: timer

Postby sashapont » Thu Jan 17, 2019 8:36 am

Yes and Print a too, because delay and pause is not usable for me I want create timer
Atari Falcon, Firebee

vido
Atari Super Hero
Atari Super Hero
Posts: 694
Joined: Mon Jan 31, 2011 7:39 pm

Re: timer

Postby vido » Thu Jan 17, 2019 9:06 am

sashapont wrote:Yes and Print a too, because delay and pause is not usable for me I want create timer

I did it with the timer function in my main loop long time ago:

    TIMER
    Syntax: t%=TIMER
    Action: TIMER suuplies the elapsed time in 1/200 seconds since the
    system was started.

    Example: t%=TIMER
    FOR i%=1 TO 2500
    NEXT i%
    PRINT (TIMER-t%)/200;" Seconds"

Code: Select all

t%=TIMER
REPEAT
  IF TIMER-t% >= 200
    IF a<2
      a=a+1
    ELSE
      a=0
    ENDIF
    t%=TIMER
  ENDIF
  >> OTHER CODE
UNTIL

It is not exactly one second but it depends how accurate timer should be and you can adjust a bit "200" value depended on the other code.


Social Media

     

Return to “GFA BASIC”

Who is online

Users browsing this forum: No registered users and 2 guests