      SUBROUTINE PLZ.PARSE.PAGE(SRC,SRC.PATH,APP.FD,DST,DST2,DST3,FV.LST,R.ERR)
*PIC-LAN
*
*ALL
*PC
*N
*
*
*
*     SRC       - Source document
*     SRC.PATH  - Path to source document
*     APP.FD    - File variable for application destination file
*
*     IMG.LST   - List of images already imported
*     INCL.NAME - Name of equate include item
*     DST       - Generated HTML source
*     DST2      - Generated VAR get source
*     DST3      - Generated MERGE load source
*     R.ERR     - Generation error
*
*
      INCLUDE SYS.TYPE.INCLUDE
*
      INCLUDE PL.COMMON
      INCLUDE PL.COMMON.DEFS
      INCLUDE PL.DEFS
      INCLUDE PLIP.COMMON
      INCLUDE PLW.COMMON
*
      INCLUDE PLZ.COMMON
*
      EQUATE SQ         TO "'"
      EQUATE DQ         TO '"'
*
      DIM D(501)
      DIM P(501)
      MAT D = ''
      MAT P = ''
      PR = ''
      N = 1
      R.ERR = ''
      DST = ''
      V.LIST = '' ;* Input variables
      C.LIST = '' ;* Checkboxes
      S.LIST = '' ;* Submit buttons
      I.LIST = '' ;* Image buttons
      R.LIST = '' ;* Radio buttons
      R.VALS = '' ;* Radio values
      M.LIST = '' ;* Select menus
      T.LIST = '' ;* Textarea variables
*
      FV.LST = ''
*
      V.CNT = 0
      VV.LST = ''
*
      UC.N = 490
*
      S = SRC
      LOOP WHILE S <> '' AND R.ERR = '' DO
         T = INDEX(S,'<',1)
         BEGIN CASE
            CASE T = 0
               D(N) = D(N) : S
               S = ''
            CASE T > 1
               D(N) = D(N) : S[1,T-1]
               S = S[T,BIG.STR]
         END CASE
*
         W = OCONV(S[1,10],'MCL')
         BEGIN CASE
            CASE W[1,5] = '<form'
               GOSUB 100
            CASE W[1,6] = '<input'
               GOSUB 100
            CASE W[1,4] = '<img'
               GOSUB 100
            CASE W[1,7] = '<select'
               GOSUB 100
               IF TRIM(S<1>) = '' THEN
                  S = DELETE(S,1,0,0)
               END
            CASE W[1,9] = '<textarea'
               GOSUB 100
               IF TRIM(S<1>) = '' THEN
                  S = DELETE(S,1,0,0)
               END
            CASE YES
               D(N) = D(N) : S[1,1]
               S = S[2,BIG.STR]
         END CASE
      REPEAT
*
      N1 = N
*
      FOR I = 1 TO N1
         IF P(I)<1,1> = 'form' THEN
            N = N + 1
         END
      NEXT I
*
      FORM.FLG = NO
      FOR I = 1 TO N1
         BEGIN CASE
            CASE P(I)<1,1> = 'form'
               IF FORM.FLG THEN
                  PRINT '*** WARNING - Page has multiple <form> ... </form> areas ***'
               END
               FORM.FLG = YES
               T = '<form method="post"'
               J1 = DCOUNT(P(I)<1,2>,SVM)
               FOR J = 1 TO J1
                  BEGIN CASE
                     CASE P(I)<1,2,J>[1,7] = 'method='
                     CASE YES
                        T = T : ' ' : P(I)<1,2,J>
                  END CASE
               NEXT J
               P(I)<1> = T : '><input type="hidden" name="PLIPCTRL" value="|PLIPCTRL|">'
            CASE P(I)<1,1> = 'input'
               GOSUB 900
               GOSUB 200
               IF R.ERR <> '' THEN RETURN
            CASE P(I)<1,1> = 'img'
               GOSUB 900
               GOSUB 300
               IF R.ERR <> '' THEN RETURN
            CASE P(I)<1,1> = 'select'
               GOSUB 900
               GOSUB 400
               IF R.ERR <> '' THEN RETURN
            CASE P(I)<1,1> = 'textarea'
               GOSUB 900
               GOSUB 500
               IF R.ERR <> '' THEN RETURN
         END CASE
      NEXT I
*
      FOR I = 1 TO 501
         DST = DST : D(I) : P(I)<1>
      NEXT I
*
      DST2 = ''
      DST3 = ''
      DST4 = ''
      I1 = DCOUNT(V.LIST,AM)
      IF I1 THEN
         DST2<-1> = '*'
      END
      FOR I = 1 TO I1
         IF V.LIST<I,3> = '' THEN
            DST2<-1> = '      PL_GETVAR2 ' : V.LIST<I,1> : ' FROM "' : V.LIST<I,2> : '"'
         END ELSE
            DST2<-1> = '      PL_GETVAR2 V$$$ FROM "' : V.LIST<I,2> : '"'
            DST2<-1> = '      ' : V.LIST<I,1> : ' = ICONV(V$$$,"' : V.LIST<I,3> : '")'
         END
      NEXT I
*
      I1 = DCOUNT(I.LIST,AM)
      IF I1 THEN
         DST2<-1> = '*'
      END
      FOR I = 1 TO I1
         DST4<-1> = '      ' : I.LIST<I,1> : ' = 0'
         DST2<-1> = '      PL_ISVAR2 ' : I.LIST<I,1> : ' FROM "' : I.LIST<I,2> : '.x"'
      NEXT I
*
      I1 = DCOUNT(S.LIST,AM)
      IF I1 THEN
         DST2<-1> = '*'
      END
      FOR I = 1 TO I1
         DST2<-1> = '      ' : S.LIST<I,1> : ' = 0'
      NEXT I
      FOR I = 1 TO I1
         DST4<-1> = '      ' : S.LIST<I,1> : ' = 0'
         DST2<-1> = '      PL_ISVAR2 ' : S.LIST<I,1> : ' FROM "' : S.LIST<I,2> : '"'
      NEXT I
*
      I1 = DCOUNT(C.LIST,AM)
      IF I1 THEN
         DST2<-1> = '*'
      END
      FOR I = 1 TO I1
         C.LIST<I,3> = 'USER.COMMON(' : UC.N : ')'
         DST3<-1> = '      ' : C.LIST<I,3> : ' = ' : C.LIST<I,1>
         DST4<-1> = '      ' : C.LIST<I,1> : ' = 0'
         DST2<-1> = '      PL_ISVAR2 ' : C.LIST<I,1> : ' FROM "' : C.LIST<I,2> : '"'
         UC.N = UC.N - 1
      NEXT I
*
      I1 = DCOUNT(R.LIST,AM)
      IF I1 THEN
         DST2<-1> = '*'
      END
      FOR I = 1 TO I1
         R.LIST<I,3> = 'USER.COMMON(' : UC.N : ')'
         DST3<-1> = '      ' : R.LIST<I,3> : ' = ' : R.LIST<I,1>
         DST2<-1> = '      PL_GETVAR2 ' : R.LIST<I,1> : ' FROM "' : R.LIST<I,2> : '"'
         UC.N = UC.N - 1
      NEXT I
*
      IF MOD(COUNT(DST,'|'),2) THEN
         R.ERR = 'Invalid insertion point syntax.'
         RETURN
      END
*
      FOR I = 1 TO COUNT(DST,'|') STEP 2
         T1 = INDEX(DST,'|',I)
         T2 = INDEX(DST,'|',I+1)
         W = DST[T1+1,T2-T1-1]
*
         BEGIN CASE
            CASE W[1,7] = 'RAW(RC$'
               WW = ''
            CASE W[1,7] = 'RAW(CC$'
               WW = ''
            CASE W[1,6] = 'RAW(M$'
               WW = ''
            CASE W[1,6] = 'RAW(T$'
               WW = ''
            CASE W[1,4] = 'RAW('
               W = W[5,LEN(W)-5]
               WW = 'RAW(USER.COMMON(' : UC.N : '))'
            CASE YES
               WW = 'USER.COMMON(' : UC.N : ')'
         END CASE
*
         IF WW <> '' THEN
            DST = DST[1,T1] : WW : DST[T2,BIG.STR]
            DST3<-1> = '      USER.COMMON(' : UC.N : ') = ' : PL_UNQUOTE(W) : ':""'
*
            UC.N = UC.N - 1
         END
      NEXT I
*
      S = ''
      S<-1> = '<pre>'
      S<-1> = 'PicLan-IP/BASIC | |'
      S<-1> = '*'
      S<-1> = '* Copyright 1998 Modular Software Corporation.  Generated ' : TIMEDATE()
*
      I1 = DCOUNT(C.LIST,AM)
      IF I1 THEN
         S<-1> = '*'
      END
      FOR I = 1 TO I1
         S<-1> = '      IF ' : C.LIST<I,3> : ' THEN'
         S<-1> = '         CC$' : I : ' = "CHECKED"'
         S<-1> = '      END ELSE'
         S<-1> = '         CC$' : I : ' = ""'
         S<-1> = '      END'
      NEXT I
*
      I1 = DCOUNT(R.LIST,AM)
      IF I1 THEN
         S<-1> = '*'
      END
      FOR I = 1 TO I1
         S<-1> = '      RC$' : I : ' = ""'
         S<-1> = '      LOCATE(' : R.LIST<I,3> : ',"' : change(R.VALS<I>,vm,svm) : '",1,1;LOC) THEN'
         S<-1> = '         RC$' : I : '<LOC> = "CHECKED"'
         S<-1> = '      END'
      NEXT I
*
      I1 = DCOUNT(M.LIST,AM)
      IF I1 THEN
         S<-1> = '*'
         DST2<-1> = '*'
      END
      FOR I = 1 TO I1
         V1 = 'USER.COMMON(' : UC.N : ')'
         DST3<-1> = '      USER.COMMON(' : UC.N : ') = ' : PL_UNQUOTE(M.LIST<I,1>) : ':""'
         UC.N = UC.N - 1
         V2 = 'USER.COMMON(' : UC.N : ')'
         DST3<-1> = '      USER.COMMON(' : UC.N : ') = ' : PL_UNQUOTE(M.LIST<I,2>) : ':""'
         UC.N = UC.N - 1
         LL = M.LIST<I,3>
         BEGIN CASE
            CASE LL = 1
               XX1 = 'AM'
               XX2 = ''
               XX3 = ''
            CASE LL = 2
               XX1 = 'VM'
               XX2 = '1,'
               XX3 = ',1'
            CASE LL = 3
               XX1 = 'SVM'
               XX2 = '1,1,'
               XX3 = ',1,1'
         END CASE
         S<-1> = '      M$' : I : ' = ' : SQ : SQ
         S<-1> = '      I1$$$ = DCOUNT(' : V1 : ',' : XX1 : ')'
         S<-1> = '      FOR I$$$ = 1 TO I1$$$'
         S<-1> = '         T$$ = ' : SQ : '<option value=' : DQ : SQ : ':I$$$:' : SQ : DQ : SQ
         S<-1> = '         LOCATE(I$$$,' : V2 : XX3 : ';LOC$$$) THEN'
         S<-1> = '            T$$ = T$$ : ' : SQ : ' SELECTED' : SQ
         S<-1> = '         END'
*$*      S<-1> = '         M$' : I : '<-1> = T$$ : ' : SQ : '>PL_QUOTE((' : V1 : ')<' : XX2 : 'I$$$>)' : SQ
         S<-1> = '         M$' : I : '<-1> = T$$ : ' : SQ : '>' : SQ : ' : PL_QUOTE((' : V1 : ')<' : XX2 : 'I$$$>)'
         S<-1> = '      NEXT I$$$'
         S<-1> = '      M$' : I : ' = PL_AMTOCRLF(M$' : I : ')'
         DST2<-1> = '      T$$ = ""'
         DST2<-1> = '      I1$$$ = DCOUNT(VAR$NAMES,AM)'
         DST2<-1> = '      FOR I$$$ = 1 TO I1$$$'
         DST2<-1> = '         IF VAR$NAMES<I$$$> = "' : M.LIST<I,4> : '" THEN'
         DST2<-1> = '            T$$<' : XX2 : '-1> = VAR$VALS(MOD(I$$$-1,500)+1)<INT((I$$$-1)/500)+1>'
         DST2<-1> = '         END'
         DST2<-1> = '      NEXT I$$$'
         DST2<-1> = '      ' : M.LIST<I,2> : ' = T$$'
      NEXT I
*
      I1 = DCOUNT(T.LIST,AM)
      IF I1 THEN
         S<-1> = '*'
         DST2<-1> = '*'
      END
      FOR I = 1 TO I1
         V1 = 'USER.COMMON(' : UC.N : ')'
         DST3<-1> = '      USER.COMMON(' : UC.N : ') = ' : PL_UNQUOTE(T.LIST<I,1>) : ':""'
         UC.N = UC.N - 1
         LL = T.LIST<I,2>
         BEGIN CASE
            CASE LL = 1
               XX1 = 'AM'
               XX2 = ''
            CASE LL = 2
               XX1 = 'VM'
               XX2 = '1,'
            CASE LL = 3
               XX1 = 'SVM'
               XX2 = '1,1,'
         END CASE
         S<-1> = '      T$' : I : ' = PL_REPL(PL_QUOTE(' : V1 : '),' : XX1 : ',CRLF)'
         DST2<-1> = '      PL_GETVAR2 T$$ FROM "' : T.LIST<I,3> : '"'
         DST2<-1> = '      ' : T.LIST<I,1> : ' = PL_REPL(T$$,CRLF,' : XX1 : ')'
      NEXT I
*
      IF DST4 <> '' THEN
         DST2 = DST4 : AM : DST2
      END
*
      T = INDEX(DST,'</body',1)
      IF NOT(T) THEN T = INDEX(DST,'</BODY',1)
      IF NOT(T) THEN
         DISPLAY CHANGE(DST,CHAR(254),CHAR(13):CHAR(10))
         R.ERR = 'Error locating </body> HTML tag'
         RETURN
      END
*
      S<-1> = '</pre>'
      DST = DST[1,T-1] : S : AM : DST[T,BIG.STR]
*
      RETURN
*
100   REM Parse HTML tag into P<N>
*
      T = INDEX(S,'>',1)
      IF NOT(T) THEN
         R.ERR = 'Invalid HTML tag construct.'
         RETURN
      END
*
      SS = S[2,T-2]
      SS = PL_REPL(SS,AM,' ')
      PR<N> = '<' : SS : '>'
      S = S[T+1,BIG.STR]
      P(N)<1,1> = OCONV(FIELD(SS,' ',1),'MCL')
      SS = SS[LEN(P(N)<1,1>)+2,BIG.STR]
*
      W = ''
      Q.FLG = NO
      FOR I = 1 TO LEN(SS)
         C = SS[I,1]
         IF C = '"' THEN
            Q.FLG = NOT(Q.FLG)
         END
         IF Q.FLG OR C <> ' ' THEN
            W = W : C
         END ELSE
            IF W <> '' THEN
               P(N)<1,2,-1> = W
               W = ''
            END
         END
      NEXT I
      IF W <> '' THEN
         P(N)<1,2,-1> = W
      END
*
      N = N + 1
*
      RETURN
*
200   REM Parse INPUT statement
*
      LOCATE('type',P.NAME;LOC) ELSE
         R.ERR = 'Cannot locate TYPE= field in ' : PR<I>
         RETURN
      END
      I.TYPE = OCONV(P.VAL<LOC>,'MCL')
      IF I.TYPE[1,1] = '"' AND I.TYPE[LEN(I.TYPE),1] = '"' THEN
         I.TYPE = I.TYPE[2,LEN(I.TYPE)-2]
      END
*
      LOCATE('name',P.NAME;N.LOC) ELSE
         R.ERR = 'Cannot locate NAME= field in ' : PR<I>
         RETURN
      END
      I.NAME = P.VAL<N.LOC>
      I.NAME = PL_UNQUOTE(I.NAME)
      IF I.NAME[1,1] = '"' AND I.NAME[LEN(I.NAME),1] = '"' THEN
         I.NAME = I.NAME[2,LEN(I.NAME)-2]
      END
      F.NAME = FIELD(I.NAME,' ',2)
      I.NAME = FIELD(I.NAME,' ',1)
*
*$*   IF F.NAME = '' THEN
*$*      LOCATE('alt',P.NAME;NN.LOC) THEN
*$*         F.NAME = P.VAL<NN.LOC>
*$*      END
*$*   END
*
      LOCATE('iconv',P.NAME;LOC) THEN
         I.CONV = P.VAL<LOC>
         P.NAME = DELETE(P.NAME,LOC,0,0)
         P.VAL  = DELETE(P.VAL ,LOC,0,0)
      END ELSE
         I.CONV = ''
      END
*
      LOCATE('oconv',P.NAME;LOC) THEN
         O.CONV = P.VAL<LOC>
         P.NAME = DELETE(P.NAME,LOC,0,0)
         P.VAL  = DELETE(P.VAL ,LOC,0,0)
      END ELSE
         O.CONV = ''
      END
*
      LOCATE('conv',P.NAME;LOC) THEN
         IF I.CONV <> '' OR O.CONV <> '' THEN
            R.ERR = 'Cannot have CONV and ICONV/OCONV on the same input field.'
            RETURN
         END
         I.CONV = P.VAL<LOC>
         O.CONV = P.VAL<LOC>
         P.NAME = DELETE(P.NAME,LOC,0,0)
         P.VAL  = DELETE(P.VAL ,LOC,0,0)
      END
*
      BEGIN CASE
         CASE I.NAME[1,1] = '_'
            P.VAL<N.LOC> = I.NAME[2,BIG.STR]
         CASE I.TYPE = 'button'
            R.ERR = 'BUTTON field is not supported in ' : PR<I>
            RETURN
         CASE I.TYPE = 'checkbox'
            N = DCOUNT(C.LIST,AM) + 1
            IF I.NAME = '' THEN
               R.ERR = 'CHECKBOX must have name ' : PR<I>
               RETURN
            END
            V = F.NAME ; GOSUB 700
            P.VAL<N.LOC> = V
            LOCATE('CHECKED',P.FLG;LOC) THEN
               P.FLG = DELETE(P.FLG,LOC,0,0)
            END
            P.FLG<-1> = '|RAW(CC$' : N : ')|'
            C.LIST<N,1> = I.NAME
            FV.LST<-1> = I.NAME
            C.LIST<N,2> = V
         CASE I.TYPE = 'file'
         CASE I.TYPE = 'hidden'
         CASE I.TYPE = 'image'
            GOSUB 800
            N = DCOUNT(I.LIST,AM) + 1
            IF I.NAME = '' THEN
               R.ERR = 'IMAGE must have name ' : PR<I>
               RETURN
            END
            V = F.NAME ; GOSUB 700
            P.VAL<N.LOC> = V
            I.LIST<N,1> = I.NAME
            FV.LST<-1> = I.NAME
            I.LIST<N,2> = V
         CASE I.TYPE = 'radio'
            IF I.NAME = '' THEN
               R.ERR = 'RADIO must have name ' : PR<I>
               RETURN
            END
            V = ''
            N = ''
            FOR II = 1 TO DCOUNT(R.LIST,AM) WHILE V = ''
               IF R.LIST<II,1> = I.NAME THEN
                  N = II
                  V = R.LIST<II,2>
               END
            NEXT II
            IF V = '' THEN
               V = F.NAME
               GOSUB 700
               N = DCOUNT(R.LIST,AM) + 1
               R.LIST<N,1> = I.NAME
               R.LIST<N,2> = V
               FV.LST<-1> = I.NAME
            END
            NN1 = DCOUNT(R.VALS<N>,VM) + 1
            LOCATE('value',P.NAME;LOC2) ELSE
               R.ERR = 'RADIO must have value ' : PR<I>
               RETURN
            END
            VAL = PL_UNQUOTE(P.VAL<LOC2>:'')
            IF VAL[1,1] = '"' AND VAL[LEN(VAL),1] = '"' THEN VAL = VAL[2,LEN(VAL)-2]
            R.VALS<N,NN1> = VAL
            P.VAL<N.LOC> = V
            LOCATE('CHECKED',P.FLG;LOC) THEN
               P.FLG = DELETE(P.FLG,LOC,0,0)
            END
            P.FLG<-1> = '|RAW(RC$' : N : '<' : NN1 : '>)|'
         CASE I.TYPE = 'reset'
         CASE I.TYPE = 'submit'
            N = DCOUNT(S.LIST,AM) + 1
            IF I.NAME = '' THEN
               R.ERR = 'SUBMIT must have name ' : PR<I>
               RETURN
            END
            V = F.NAME ; GOSUB 700
            P.VAL<N.LOC> = V
            S.LIST<N,1> = I.NAME
            S.LIST<N,2> = V
            FV.LST<-1> = I.NAME
         CASE I.TYPE = 'text' OR I.TYPE = 'password'
            N = DCOUNT(V.LIST,AM) + 1
            IF I.NAME = '' THEN
               R.ERR = 'TEXT/PASSWORD must have name ' : PR<I>
               RETURN
            END
            V = F.NAME ; GOSUB 700
            P.VAL<N.LOC> = V
            LOCATE('value',P.NAME;LOC) THEN
               P.NAME = DELETE(P.NAME,LOC,0,0)
               P.VAL  = DELETE(P.VAL ,LOC,0,0)
            END
            P.NAME<-1> = 'value'
            IF O.CONV = '' THEN
               T = I.NAME
            END ELSE
               T = 'OCONV(' : I.NAME : ',"' : O.CONV : '")'
            END
            P.VAL<-1>  = '|' : PL_QUOTE(T) : '|'
            V.LIST<N,1> = I.NAME
            V.LIST<N,2> = V
            FV.LST<-1> = I.NAME
            V.LIST<N,3> = I.CONV
         CASE YES
            R.ERR = 'Invalid TYPE= field in INPUT statement.'
            RETURN
      END CASE
*
      T = '<input'
      J1 = DCOUNT(P.NAME,AM)
      FOR J = 1 TO J1
         T = T : ' ' : P.NAME<J> : '="' : P.VAL<J> : '"'
      NEXT J
      J1 = DCOUNT(P.FLG,AM)
      FOR J = 1 TO J1
         T = T : ' ' : P.FLG<J>
      NEXT J
      T = T : '>'
      P(I)<1> = T
*
      RETURN
*
300   REM parse img
*
      GOSUB 800
*
      T = '<img'
      J1 = DCOUNT(P.NAME,AM)
      FOR J = 1 TO J1
         T = T : ' ' : P.NAME<J> : '="' : P.VAL<J> : '"'
      NEXT J
      J1 = DCOUNT(P.FLG,AM)
      FOR J = 1 TO J1
         T = T : ' ' : P.FLG<J>
      NEXT J
      T = T : '>'
      P(I)<1> = T
*
      RETURN
*
400   REM Parse SELECT statement
*
      LOCATE('name',P.NAME;N.LOC) ELSE
         R.ERR = 'Cannot locate NAME= field in ' : PR<I>
         RETURN
      END
      I.NAME = P.VAL<N.LOC>
      I.NAME = PL_UNQUOTE(I.NAME)
      IF I.NAME[1,1] = '"' AND I.NAME[LEN(I.NAME),1] = '"' THEN
         I.NAME = I.NAME[2,LEN(I.NAME)-2]
      END
*
      BEGIN CASE
         CASE I.NAME[1,1] = '_'
            P.VAL<N.LOC> = P.VAL<N.LOC>[2,BIG.STR]
            LL = 0
         CASE YES
            V1 = FIELD(I.NAME,' ',1)
            V2 = FIELD(I.NAME,' ',2)
            F.NAME = FIELD(I.NAME,' ',3)
            LL = DCOUNT(V1,',')
            IF INDEX(V1,'<',1) THEN LL = LL + 1
            IF LL < 1 OR LL > 3 THEN
               R.ERR = 'Invalid variable definition in SELECT in line ' : PR<I>
               RETURN
            END
*
            V = F.NAME ; GOSUB 700
            P.VAL<N.LOC> = V
            N = DCOUNT(M.LIST,AM) + 1
            M.LIST<N,1> = V1
            M.LIST<N,2> = V2
            M.LIST<N,3> = LL
            M.LIST<N,4> = V
      END CASE
*
      T = '<select'
      J1 = DCOUNT(P.NAME,AM)
      FOR J = 1 TO J1
         T = T : ' ' : P.NAME<J> : '="' : P.VAL<J> : '"'
      NEXT J
      J1 = DCOUNT(P.FLG,AM)
      FOR J = 1 TO J1
         T = T : ' ' : P.FLG<J>
      NEXT J
      T = T : '>'
      IF LL THEN
         T = T : '|RAW(M$' : N : ')|'
      END ELSE
         T = T : AM
      END
      P(I)<1> = T
*
      RETURN
*
500   REM Parse TEXTAREA statement
*
      LOCATE('name',P.NAME;N.LOC) ELSE
         R.ERR = 'Cannot locate NAME= field in ' : PR<I>
         RETURN
      END
      I.NAME = P.VAL<N.LOC>
      I.NAME = PL_UNQUOTE(I.NAME)
      IF I.NAME[1,1] = '"' AND I.NAME[LEN(I.NAME),1] = '"' THEN
         I.NAME = I.NAME[2,LEN(I.NAME)-2]
      END
      F.NAME = FIELD(I.NAME,' ',2)
      I.NAME = FIELD(I.NAME,' ',1)
*
      BEGIN CASE
         CASE I.NAME[1,1] = '_'
            P.VAL<N.LOC> = P.VAL<N.LOC>[2,BIG.STR]
            LL = 0
         CASE YES
            LL = DCOUNT(I.NAME,',')
            IF INDEX(I.NAME,'<',1) THEN LL = LL + 1
            IF LL < 1 OR LL > 3 THEN
               R.ERR = 'Invalid variable definition in TEXTAREA in line ' : PR<I>
               RETURN
            END
*
            V = F.NAME ; GOSUB 700
            P.VAL<N.LOC> = V
            N = DCOUNT(T.LIST,AM) + 1
            T.LIST<N,1> = I.NAME
            T.LIST<N,2> = LL
            T.LIST<N,3> = V
      END CASE
*
      T = '<textarea'
      J1 = DCOUNT(P.NAME,AM)
      FOR J = 1 TO J1
         T = T : ' ' : P.NAME<J> : '="' : P.VAL<J> : '"'
      NEXT J
      J1 = DCOUNT(P.FLG,AM)
      FOR J = 1 TO J1
         T = T : ' ' : P.FLG<J>
      NEXT J
      T = T : '>'
      IF LL THEN
         T = T : '|RAW(T$' : N : ')|'
      END ELSE
         T = T : AM
      END
      P(I)<1> = T
*
      RETURN
*
700   REM Verify or set V
*
      IF V = '' THEN
         V.CNT = V.CNT + 1
         V = V.CNT
      END
*
      LOCATE(V,VV.LST;LLOC) THEN
         R.ERR = 'Duplicate variable ' : V
      END ELSE
         VV.LST<-1> = V
      END
*
      RETURN
*
800   REM move image
*
      LOCATE('src',P.NAME;LOC) ELSE
         R.ERR = 'Cannot locate "src" for image.'
         RETURN
      END
*
      S.PATH = P.VAL<LOC>
      IF S.PATH[1,1] = '/' THEN RETURN
      IF S.PATH[1,1] = '\' THEN RETURN
      IF I.OPT THEN RETURN
      IF OCONV(S.PATH[1,5],'MCL') = 'http:' THEN RETURN
      IF OCONV(S.PATH[1,5],'MCL') = 'file:' THEN
         PRINT '*** Warning FILE image reference ' : S.PATH : ' ***'
         RETURN
      END
*
      TP = FIELD(SRC.PATH,' ',1)
      BEGIN CASE
         CASE TP = 'FILE'
            PATH = FIELD(SRC.PATH,' ',3)
            I.PATH = 'FILE ' : FIELD(SRC.PATH,' ',2)
         CASE TP = 'HOST'
            PATH = FIELD(SRC.PATH,' ',2)
            I.PATH = 'HOST'
         CASE TP = 'DSG'
            PATH = FIELD(SRC.PATH,' ',3)
            I.PATH = 'DSG ' : FIELD(SRC.PATH,' ',2)
         CASE YES
            R.ERR = 'Invalid document source TP ' : TP
            RETURN
      END CASE
*
      DOC = FIELD(S.PATH,'/',COUNT(S.PATH,'/')+1)
*
      LOCATE(DOC,IMG.LST;DUMMY) THEN RETURN
*
      IF INDEX(PATH,'/',1) THEN
         PATH = PATH[1,INDEX(PATH,'/',COUNT(PATH,'/'))-1]
      END ELSE
         PATH = ''
      END
*
      CALL PLU.CAT.PATHS(PATH,S.PATH,D.PATH)
*
      CALL PLU.READ.FILE(I.PATH:' ':D.PATH,'X',IMG.DOC)
*
      IF LEN(IMG.DOC) < 10 THEN
         PRINT '*** Image ' : I.PATH : ' ' : D.PATH : ' not imported.'
         RETURN
      END
*
      WRITE IMG.DOC ON APP.FD , OCONV(DOC,'MCU')
*
      P.VAL<LOC> = DOC
      IMG.LST<-1> = DOC
*
      RETURN
*
900   REM parse name/val pairs
*
      P.NAME = ''
      P.VAL  = ''
      P.FLG = ''
      J1 = DCOUNT(P(I)<1,2>,SVM)
      FOR J = 1 TO J1
         IF INDEX(P(I)<1,2,J>,'=',1) THEN
            NAME = OCONV(FIELD(P(I)<1,2,J>,'=',1),'MCL')
            VAL  = OCONV(P(I)<1,2,J>,'G1=999')
            IF VAL[1,1] = '"' AND VAL[LEN(VAL),1] = '"' THEN
               VAL = VAL[2,LEN(VAL)-2]
            END
            LOCATE(NAME,P.NAME;LOC) THEN
               R.ERR = 'Bad INPUT construct ' : PR<I>
               RETURN
            END
            P.NAME<-1> = NAME
            P.VAL<-1>  = VAL
         END ELSE
            P.FLG<-1> = OCONV(P(I)<1,2,J>,'MCU')
         END
      NEXT J
*
      RETURN
   END
