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

      PROGRAM MAIN

      INTEGER*2 PAGES
      PARAMETER (PAGES=4)

      INTEGER*2 COLOR
      INTEGER*2 OLD_MODE
      INTEGER*2 PAGE
      CHARACTER*6 STRING
      INTEGER*2 FG_GETMAXX, FG_GETMAXY, FG_GETMODE, FG_TESTMODE

      IF (FG_TESTMODE(13,PAGES) .EQ. 0) THEN
         STOP 'This program requires a 320 x 200 EGA graphics mode.'
      END IF

      OLD_MODE = FG_GETMODE()
      CALL FG_SETMODE(13)

      DO 10 PAGE = 0,PAGES-1
         CALL FG_SETPAGE(PAGE)
         COLOR = PAGE + 1
         CALL FG_SETCOLOR(COLOR)
         CALL FG_RECT(0,FG_GETMAXX(),0,FG_GETMAXY())
         CALL FG_SETCOLOR(0)
         CALL FG_LOCATE(12,17)
         WRITE(STRING,1000) PAGE
         CALL FG_TEXT(STRING,6)
10    CONTINUE

      DO 20 PAGE = 0,PAGES-1
         CALL FG_SETVPAGE(PAGE)
         CALL FG_WAITKEY
20    CONTINUE

      CALL FG_SETMODE(OLD_MODE)
      CALL FG_RESET

      STOP ' '
1000  FORMAT('page',I2)
      END
