  #compact
  % filename "t.exe"
 'uses RTL64
  % Title "Console Grid Input Demo"
 '% Animated
  % ScaleUp
 '% PlaceCentral
 '% AnchorCentral
 '% NoEscape

  $ filename "t.exe"
 'uses RTL64
  uses ConsoleG

  procedure main()
  ================
  sys a,i,p
  static string ins
  static string s
  static string dat[10,10]

  if opening
    'INTIAL EXAMPLE DATA
    int x,y
    for y=1 to 5
      for x=1 to 5
        dat[y,x]="y"str(y)+" x"+str(x)
      next
    next
  endif


  cls .10,.10,.20
  '
  'GRID INPUTS
  ------------
  scale 1.5
  int x,y
  for y=1 to 5
    for x=1 to 5
      PushState
      move x*4,-y*2
      if pick
        'MARK PICKING AREA
        picklabel y*10+x
        move 0,0,-.01
        PutBoxArea 3,1
      else
        if picked=y*10+x
          'DATA EDITING
          color 0.9,.9,0.9
          a=input dat[y,x]
          lastkey=0
          lastchar=0
        else
          'DATA DISPLAY
          move 0,0,-.01
          color .3,.4,.3
          PutBoxArea 3,1
          move 0.2,0.2,.01
          color .8,.8,.6
          print dat[y,x]
        endif
      endif
      PopState
    next
  next
  scale 1/1.5
  printl str(picked)
  '
  end procedure

  EndScript
