News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

Timer disabled in BASIC

Started by ivavilagu, 15:43, 08 December 21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ivavilagu

Hi,
I have a countdown timer with 'EVERY' command. When the count reaches zero it disables with the function 'REMAIN'. It works fine.
But once disabled I can´t enable again the same counter. Remain function disables timer permanently?




abalore

Why don't you better use AFTER?

abalore

About your specific question, you must be sure you leave the timer subroutine with RETURN in order to be able to use the timer again. If it still fails try calling EI to enable interrupts.

ivavilagu

#3
I need to use EVERY for update the screen clock every second.
I don´t understand the RETURN command in this case. Where returned  when time is over?



IF second<>0THEN RETURN ELSE c=REMAIN(0):c$="GAME OVER":RETURN


I need to make a GOTO when game is over in order to start again.




Cohone, que somos los dos españoles, ¿se puede postear en castellano?




andycadley

You need to RETURN from an EVERY subroutine or you will eventually run out of stack space. And it will return to whatever command was executing before the event triggered.


The trick to doing this sort of thing is to have the main block of code executing in a WHILE loop, checking a status variable to see if time has run out and then have your timer setting this variable.

ivavilagu

Thanks, changed main loop and works!

Powered by SMFPacks Menu Editor Mod