$INCLUDE: 'C:\FG\FASTGRAF.FI'

      PROGRAM MAIN

      INTEGER I, J
      INTEGER MODE, STATUS
      INTEGER MINX, MAXX, MINY, MAXY
      INTEGER*1 PCXPAL(768)
      INTEGER*1 HEADER(128)
      INTEGER FG_PCXHEAD, FG_PCXMODE, FG_PCXPAL

      CALL FG_INITPM
      STATUS = FG_PCXHEAD('CORAL.PCX'//CHAR(0),HEADER)
      IF (STATUS .EQ. -1) THEN
         STOP 'Can''t open CORAL.PCX.'
      ELSE IF (STATUS .EQ. -2) THEN
         STOP 'CORAL.PCX is not a PCX file.'
      END IF

      MODE = FG_PCXMODE(HEADER)
      WRITE(6,10) MODE
10    FORMAT (' Optimal display mode is',I3,'.')

      CALL FG_PCXRANGE(HEADER,MINX,MAXX,MINY,MAXY)
      WRITE(6,20) MAXX-MINX+1, MAXY-MINY+1
20    FORMAT(' Image size is ',I3,' by ',I3,' pixels.')

      STATUS = FG_PCXPAL('CORAL.PCX'//CHAR(0),PCXPAL)
      WRITE(6,*) 'First 16 palette values are:'
      J = 1
      DO 40 I = 1,16
         WRITE(6,30) I,PCXPAL(J),PCXPAL(J+1),PCXPAL(J+2)
30       FORMAT('   color ',I2,': R=',I2,' G=',I2,' B=',I2)
         J = J + 3
40    CONTINUE

      STOP ' '
      END
