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

      PROGRAM MAIN

      INTEGER*2 ROW
      INTEGER*2 NEW_MODE, OLD_MODE
      INTEGER*2 STATUS
      CHARACTER*20 STRING
      INTEGER*2 FG_ALLOCATE, FG_FREEPAGE
      INTEGER*2 FG_BESTMODE, FG_GETMODE

      NEW_MODE = FG_BESTMODE(320,200,2)
      IF (NEW_MODE .LT. 0 .OR. NEW_MODE .EQ. 12) THEN
         STOP 'This program requires a 320 x 200 color graphics mode.'
      END IF
      OLD_MODE = FG_GETMODE()
      CALL FG_SETMODE(NEW_MODE)

      CALL FG_SETCOLOR(7)
      CALL FG_RECT(0,319,0,199)
      CALL FG_SETCOLOR(9)

      DO 10 ROW = 0,24
         WRITE(STRING,1000) ROW
         CALL FG_LOCATE(ROW,0)
         CALL FG_TEXT(STRING,20)
         CALL FG_TEXT(STRING,20)
10    CONTINUE
      CALL FG_WAITKEY

      STATUS = FG_ALLOCATE(1)
      CALL FG_SETHPAGE(1)
      CALL FG_SAVE(96,223,88,111)
      CALL FG_SETCOLOR(1)
      CALL FG_RECT(96,223,88,111)
      CALL FG_SETCOLOR(15)
      CALL FG_LOCATE(12,13)
      CALL FG_TEXT('Press any key.',14)
      CALL FG_WAITKEY

      CALL FG_RESTORE(96,223,88,111)
      CALL FG_WAITKEY

      STATUS = FG_FREEPAGE(1)
      CALL FG_SETMODE(OLD_MODE)
      CALL FG_RESET

      STOP ' '
1000  FORMAT('   This is row ',I2,3X)
      END
