      SUBROUTINE PLW.ERROR(R.ERR)
*PIC-LAN
*
*ALL
*PC
*N
*
*
*
*
      INCLUDE SYS.TYPE.INCLUDE
*
      INCLUDE PL.COMMON
      INCLUDE PL.COMMON.DEFS
      INCLUDE PL.DEFS
      INCLUDE PLIP.COMMON
      INCLUDE PLW.COMMON
*
      OPEN 'WWW.CTRL,LOCAL.PAGES' TO LOCAL.FD ELSE CALL PLXX.STOP(201,'WWW.CTRL,LOCAL.PAGES')
*
      PL_PUTVAR R.ERR IN '_ERROR' ELSE NULL
*
      ERROR0 = R.ERR
*
      GOSUB 100
*
      IF RESX = '' THEN
         MAT CTRL$ARRAY = ''
         CTRL$MIME = 'text/plain'
         IF FIELD(R.ERR,' ',1) <> '304' THEN
            ERRSTR = FIELD(R.ERR,';',2)
            IF ERRSTR = '' THEN
               ERRSTR = 'Undefined error ' : R.ERR
            END
            CALL PLU.WRAP.TEXT(60,ERRSTR:'',ERRSTR)
            RESX = PL_AMTOCRLF(ERRSTR:AM)
         END
         R.ERR = FIELD(R.ERR,';',1)
      END
*
      R.ERR = ERROR0
*
      RETURN
*
100   REM
*
      ERR.NO = FIELD(FIELD(R.ERR,';',1),' ',1)
*
      IF NOT(NUM(ERR.NO)) THEN
         CALL PLW.PAGE('/&ERR_UND.HTM','',R.ERR)
         RETURN
      END
*
      ERR.SUB = FIELD(FIELD(FIELD(R.ERR,':',1),'[',1),']',1)
      ERR.LOC = FIELD(ERR.SUB,':',2)
      ERR.SUB = FIELD(ERR.SUB,':',1)
*
      BEGIN CASE
         CASE ERR.SUB = ''
            ID = 'ERR_' : ERR.NO : '.HTM'
            READV DUMMY FROM LOCAL.FD , ID , 1 ELSE ID = ''
         CASE ERR.LOC = ''
            ID = 'ERR_' : ERR.NO : '_' : ERR.SUB : '.HTM'
            READV DUMMY FROM LOCAL.FD , ID , 1 ELSE
               ID = 'ERR_' : ERR.NO : '.HTM'
               READV DUMMY FROM LOCAL.FD , ID , 1 ELSE ID = ''
            END
         CASE YES
            ID = 'ERR_' : ERR.NO : '_' : ERR.SUB : '_' : ERR.LOC : '.HTM'
            READV DUMMY FROM LOCAL.FD , ID , 1 ELSE
               ID = 'ERR_' : ERR.NO : '_' : ERR.SUB : '.HTM'
               READV DUMMY FROM LOCAL.FD , ID , 1 ELSE
                  ID = 'ERR_' : ERR.NO : '.HTM'
                  READV DUMMY FROM LOCAL.FD , ID , 1 ELSE ID = ''
               END
            END
      END CASE
*
      IF ID = '' THEN
         CALL PLW.PAGE('/&ERR_UND.HTM','',R.ERR)
         RETURN
      END
*
      CALL PLW.PAGE('/&' : ID,'',R.ERR)
*
      RETURN
   END
