$INCLUDE: 'C:\FG\INTRFACE.FOR'

      PROGRAM MAIN

      INTEGER*2 OLD_MODE
      INTEGER*2 BUTTONS, COUNT
      INTEGER*2 X, Y
      CHARACTER*24 STRING
      INTEGER*2 FG_AUTOMODE, FG_GETMAXX, FG_GETMAXY
      INTEGER*2 FG_GETMODE, FG_MOUSEINI, FG_XCONVERT, FG_YCONVERT

      OLD_MODE = FG_GETMODE()
      CALL FG_SETMODE(FG_AUTOMODE())

      IF (FG_MOUSEINI() .LT. 0) THEN
         CALL FG_SETMODE(OLD_MODE)
         CALL FG_RESET
         STOP ' '
      END IF

      CALL FG_SETCOLOR(15)
      CALL FG_RECT(0,FG_GETMAXX(),0,FG_GETMAXY())
      CALL FG_MOUSEVIS(1)

10    CALL FG_WAITFOR(54)
      CALL FG_MOUSEBUT(1,COUNT,X,Y)
      CALL FG_MOUSEPOS(X,Y,BUTTONS)
      WRITE(STRING,1000) X, Y, COUNT
      CALL FG_MOUSEVIS(0)
      CALL FG_SETCOLOR(15)
      CALL FG_RECT(0,FG_XCONVERT(25),0,FG_YCONVERT(1))
      CALL FG_SETCOLOR(0)
      CALL FG_LOCATE(0,0)
      CALL FG_TEXT(STRING,24)
      CALL FG_MOUSEVIS(1)
      CALL FG_MOUSEBUT(2,COUNT,X,Y)
      IF (COUNT .EQ. 0) GO TO 10

      CALL FG_SETMODE(OLD_MODE)
      CALL FG_RESET

      STOP ' '
1000  FORMAT('X=',I3,'  Y=',I3,'  count=',I4)
      END
