//-----------------------------------------------------------------------
// Test program for PGPLOT: test of Cursor
//-----------------------------------------------------------------------

      print "   This program demonstrates the use of routine PGBAND. It"
      print "   requires a graphics device with a cursor. Position the cursor"
      print "   anywhere in the window. Press any key (or a mouse button if"
      print "   the device has a mouse supported by PGPLOT); the program"
      print "   draws a marker at the current cursor position and reports the"
      print "   current cursor position [bottom left corner is (0,0); top"
      print "   right is (1,1)] and the ASCII code of the key that you"
      print "   pressed. To exit from the program, type a slash (/), ctrl-D,"
      print "   or ctrl-Z. The + key toggles between normal cursor, cross-hair,"
      print "   and other cursor modes (on supporting devices)."

// Open device for graphics.

      if (pgbeg(0,plotdevice,1,1) != 1) break

// Clear the screen. Draw a frame at the physical extremities of the
// plot, using full-screen viewport and standard window.
//
      pgpage
      pgsvp 0.0,1.0,0.0,1.0
      pgswin 0.0,1.0,0.0,1.0
      pgbox "bcts",0.1,5,"bcts",0.1,5

// Loop to read and display cursor position. Initial position for cursor
// is center of viewport. 

      X = 0.5
      Y = 0.5
      MODE = 0
      CH = "A"
      en = 0
      while (en != 1) {
        JUNK = pgband(MODE, 1, X, Y, X,Y,CH)
        print "" + X + Y //+ int(CH)
//      Check for exit
        if (CH == "/" || CH == char(0) || CH == char(4) || CH == char(26)) {
          en = 1
        } else {
//      Check for switch of cursor type.
          if (CH == "+") {
            MODE = (MODE+1) % 8
            print "Cursor mode: " + MODE
          } else {
            pgpt1 X, Y, 33//int(CH)
          }
        }
      }

// Close the device and exit.

      pgend
      
