 #compact 
 % Title "ConsoleG Demo: Timing"

  % WindowStyle WS_OVERLAPPEDWINDOW
  % Animated
 '% ScaleUp
 '% PlaceCentral
 '% AnchorCentral

 '% shaders

 uses ConsoleG
 
  BeginScript

  sub main
  ========

  'WaitForEvent '0 off 1 on (default on)
  static int  z, y, x
  static quad t1,t2

  if opening then 'FIRST CALL ONLY
    timemark t1
  end if

  if closing then 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    'exit sub
  end if

  if not pick then
    pushstate
    move 0,0
    static sys tally
    timemark t2
    scale 1.5
    double td=timediff(t2,t1)
    SYSTEMTIME st : getLocalTime st
    '
    macro pr(a,b) 'PRINTING LIST
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 8 : print b : popstate
      printl ""
    end macro
    '
    pr "System Time:   ", left(timeStr(st),21)
    pr "Lapsed Time:   ", str(td,3)+"  "
    pr "10ms Count:    ", str(tickCount*2)
    pr "Frame Count:   ", str(tally++)
   'pr "Action Code:   ", str(act)
   'pr "Picked ID:     ", str(picked)
   'pr "Keyboard Code: ", str(keyd)

    popstate
  end if
   if td>5 then
     CloseScene
   end if

  end sub 'main

  EndScript