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

      PROGRAM MAIN

      INTEGER*2 NEW_MODE, OLD_MODE
      REAL*8 XMIN, XMAX, YMIN, YMAX
      INTEGER*2 FG_AUTOMODE, FG_GETMODE

      OLD_MODE = FG_GETMODE()
      NEW_MODE = FG_AUTOMODE()

      IF (NEW_MODE .EQ. 0) THEN
         STOP 'This program requires graphics.'
      END IF

      CALL FG_SETMODE(NEW_MODE)
      CALL FG_INITW

      CALL FG_SETWORLD(0.0,40.0,0.0,30.0)
      CALL REDRAW
      CALL FG_WAITKEY

      CALL FG_GETWORLD(XMIN,XMAX,YMIN,YMAX)
      CALL FG_SETWORLD(0.0,XMAX*0.5,0.0,YMAX*0.5)
      CALL REDRAW
      CALL FG_WAITKEY

      CALL FG_SETMODE(OLD_MODE)
      CALL FG_RESET

      STOP ' '
      END

      SUBROUTINE REDRAW

      CALL FG_ERASE
      CALL FG_SETCOLOR(1)

      CALL FG_MOVEW(0.0,0.0)
      CALL FG_DRAWW(0.0,10.0)
      CALL FG_DRAWW(10.0,10.0)
      CALL FG_DRAWW(10.0,0.0)
      CALL FG_DRAWW(0.0,0.0)

      RETURN
      END
