Menu

Strange results from TIMER in 1.27-58 in Windows 10 32-bit

2019-07-07
2019-07-09
  • Yet Another Troll

    TIMER is behaving strangely in 1.27-58-unstable in Windows 10 32-bit [Version 10.0.17763.593] when multiple xbasic instances are running,

    C:\Program Files\X11-Basic>contrib\ansicon xbasic
    **********************************************************
    *     sdlxbasic                     V.1.27              *
    *                       by Markus Hoffmann 1997-2019 (c) *
    ***  sdl la      gmp         snd                       ***
    * version date:            Mon Jul  1 15:04:58 CEST 2019 *
    * library V.1.27 date:     Mon Jul  1 15:04:58 CEST 2019 *
    **********************************************************
    
    > ver
    X11-BASIC Version: 1.27 Jul  1 2019 15:30:25
    > ? timer
    11.639
    > ? timer
    13.386
    > ? timer
    14.481
    > ? unixdate$(timer)
    31.12.1969
    >
    
     
  • Markus Hoffmann

    Markus Hoffmann - 2019-07-07

    Yea, the timer-value on WINDOWS resets to zero every time the interpreter restarts. I do not think that there is a system timer like on UNIX machines. But one can implement one maybe calculating the UNIXtimer from the clock values. Maybe this would be a good issue for improvement.

    Corrently the TIMER does following on WINDOWS:
    return((double)clock()/CLOCKS_PER_SEC);
    So it uses the OS function "clock()".

    I was partially wrong: STIMER works and gives the UNIX-timestamp of the current local time.
    However there are no milliseconds. SO maybe It is just a matter of combining the two. This would not be too hard to do.

     

    Last edit: Markus Hoffmann 2019-07-07
  • Markus Hoffmann

    Markus Hoffmann - 2019-07-07

    I have fixed this now. TIMER now behaves the same on WINDOWS, LINUX and ANDROID. Can be tested in the next release (1.27-59).

     
    • Yet Another Troll

      Thanks! In good news, MODE() appears to behave reasonably in Windows 10 32-bit, even if it doesn't clearly detect online-only OneDrive files,

      C:\Program Files\X11-Basic>contrib\ansicon xbasic
      **********************************************************
      *     sdlxbasic                     V.1.27              *
      *                       by Markus Hoffmann 1997-2019 (c) *
      ***  sdl la      gmp         snd                       ***
      * version date:            Mon Jul  1 15:04:58 CEST 2019 *
      * library V.1.27 date:     Mon Jul  1 15:04:58 CEST 2019 *
      **********************************************************
      
      > ? dir$(0)
      C:\Program Files\X11-Basic
      > ? bin$(mode("."))
      100000111111111
      > ? bin$(mode("xbc.exe"))
      1000000111111111
      > ? bin$(mode("doc"))
      100000111111111
      > ? oct$(mode("doc"))
      40777
      > ? oct$(mode("xbc.exe"))
      100777
      > ? oct$(mode("\users\trollollio\onedrive\music\cozmo's air.mp3"))
      100444
      > ver
      X11-BASIC Version: 1.27 Jul  1 2019 15:30:25
      > ? oct$(mode("bas.ico"))
      100666
      >
      

      I'm not quite sure how Windows file attributes should map to MODE's in every case,

      https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants

       

      Last edit: Yet Another Troll 2019-07-07
    • Yet Another Troll

      Looks good. There could be some rounding or race condition weirdness going on between TIMER and STIMER, but I can work with this. Thank you.

      C:\Program Files\X11-Basic>contrib\ansicon xbasic
      **********************************************************
      *     sdlxbasic                     V.1.27               *
      *                       by Markus Hoffmann 1997-2019 (c) *
      ***  sdl la      gmp         snd                       ***
      * version date:            Mon Jul  8 12:44:07 CEST 2019 *
      * library V.1.27 date:     Mon Jul  8 12:44:07 CEST 2019 *
      **********************************************************
      
      > ver
      X11-BASIC Version: 1.27 Jul  8 2019 12:44:26
      > ? dir$(0)
      C:\Program Files\X11-Basic
      > ? env$("tmp")
      C:\Users\trollollio\AppData\Local\Temp
      > ? stimer, timer
      1562597939      1562597939
      > ? stimer, timer
      1562597941      1562597940.953
      > ? stimer, timer
      1562597943      1562597942.671
      > ? stimer, timer
      1562597946      1562597945.765
      > ? stimer, timer
      1562597977      1562597977.515
      > ? stimer, timer
      1562597980      1562597980.468
      
       
  • Markus Hoffmann

    Markus Hoffmann - 2019-07-09

    I am using the system timer of WINDOWS plus a UNIX timestamp saved when the TIMER was first used. So this means: STIMER and TIMER can be off by up to 1 Second. Also maybe the systemtimer is not in sync with the clock. So STIMER and TIMER can slightly drift away.

     

Log in to post a comment.

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.