  #compact
  %filename "t.exe"
 'uses RTL64
 '% Title "Create Points and Lines Demo"
  % Title "ConsoleG Demo:  Move text with mouse and arrow keys etc"

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

  % shaders

  uses consoleG
 
  'Keys: Esc, arrow-keys, n,m, F4

  BeginScript

  procedure main
  ==============

  'WaitForEvent '0 off 1 on (default on)
  static quad t1,t2

  if opening then 'FIRST CALL ONLY
    'picked=100
    'mbox "helo"
  end if
  '
  if closing then 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    exit sub
  end if
  cls 0,.4,0
  shading
  'CREATE POINTS
  if opening
    %n 100
    static MoveableObject mu[n]
    '#recordof a
    scope
      int i=n
      int k=100
      for i=1 to n
        mu[i].mode=0x101
        k+=100
        mu[i].id=k
      next
    end scope
  endif
  scale 1
  int i, j
  thickness 3
  for i=1 to 20
    pushstate
    mu[i].act 'FIXES LOCATION
    if mu[i].x + mu[i].y = 0
      color .9,.9,.9,1
    else
      color .9,.5,0,1
    endif
    go sphere
    popstate
  next
  '
  flat
  for i=1 to 20
    j=i+1
    if mu[i].x + mu[i].y <> 0
      if mu[j].x + mu[j].y <> 0 
        'DRAW LINE BETWEEN POINTS
        'INCLUDE D.X D.Y MOUSE DRAG
        glbegin GL_LINES
        glVertex3f mu[i].x+mu[i].d.x, mu[i].y+mu[i].d.y, 0
        glVertex3f mu[j].x+mu[j].d.x, mu[j].y+mu[j].d.y, 0
        glend
      endif
    endif
  next
  shading
  picklabel 0

  move 5,0

  'if not pick then
    if key[49] then picked=100 'keypress '1'
    if key[50] then picked=200 'kypress  '2'
    pushstate
    move -20,12
    static sys tally
    timemark t2
    scale 1.0
    '
    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
    picklabel 10
   'pr "Action Code:   ", str(act)
   'pr "indexbase      ", str(indexbase)
    pr "Picked ID:     ", str(picked)
    pr "Keyboard Code: ", str(keyd)
    picklabel 0
    popstate
  'end if

  end procedure 'main

  EndScript