Menu

The very first ON TIMER(n) statement gets trapped immediately

2017-02-04
2017-02-04
  • Francis Lee

    Francis Lee - 2017-02-04

    Hi Rob,

    First of all, thank you very much for creating and maintaining this wonderful project! I enjoyed programming in GW-BASIC when I was young and now PC-BASIC is providing me the same experience on my Windows PC with just one click on the nice "Ok" icon.

    I was learning and testing ON KEY / ON TIMER statement, and I believe I found a bug in ON TIMER(n) stetement implementation. Below is the code I was experimenting with:

    10 CLS
    15 PRINT "Press UP arrow key to exit...
    20 ON KEY(11) GOSUB 80
    30 KEY(11) ON
    32 ON TIMER(1) GOSUB 100
    34 TIMER ON
    40 FOR I=1 TO 10
    50 PRINT "Hello, World!
    60 NEXT I
    70 GOTO 70
    80 KEY(11) OFF:PRINT "Removing KEY(11) trap setting...
    90 END
    100 PRINT "Hello, every one second!
    110 RETURN 70 'go to infinite loop
    

    I was expecting "Hello, World!" to be printed first 10 times, followed by "Hello, every one second!" later every one second, however, "Hello, World!" never gets printed at all. "Hello, every one second!" gets printed immediately after TIMER ON statement. BTW, print statement without the terminating double quote was written intentionally in such style after learning that LOAD/SAVE/CHDIR statement works fine like.

    Thanks,
    Francis

     
  • Francis Lee

    Francis Lee - 2017-02-04

    Hi Rob,

    I also found that KEY(11) OFF is not required in GW-BASIC 3.23 (with dosbox) when the program is terminiated, however without this statement, the UP arrow key is not responding anymore in PC-BASIC.

    Thanks,
    Francis

     
  • Rob Hagemans

    Rob Hagemans - 2017-02-06

    Hi Francis,

    Thanks for reporting this - I'll have a look.

    Rob

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.