      SUBROUTINE PLH.BLD.TABLE(CMD,TBL.OPTIONS,N.COLS,COL.WIDTHS,CELL.CONTENTS,CELL.OPTIONS,RES)
*PIC-LAN
*
*ALL
*PC
*Y
*
*
*
      RES = ''
******************************************************************************
******************************************************************************
***                                                                        ***
*** (C) Copyright 1990-2005 Doug Dumitru, All Rights Reserved.             ***
***                                                                        ***
*** This program is licensed under the terms of the GNU General Public     ***
*** License, version 2.0 with attached notices.                            ***
***                                                                        ***
*** The full text can be found in the LICENSE.TXT file in the              ***
*** PLIP.BP database file (the /usr/qmweb/PLIP.BP/PLIP.BP directory).      ***
***                                                                        ***
******************************************************************************
******************************************************************************
*
*
      V.FLG = ( INDEX(OCONV(CMD,'MCU'),'V',1) <> 0 )
      I.FLG = ( INDEX(OCONV(CMD,'MCU'),'I',1) <> 0 )
*
      CALL PLH.TO.ATTRS(COL.WIDTHS,C.WID)
      CALL PLH.TO.ATTRS(CELL.CONTENTS,C.DATA)
      CALL PLH.TO.ATTRS(CELL.OPTIONS ,C.OPTS)
*
      IF I.FLG THEN
         I4 = '    '
         I8 = '        '
      END ELSE
         I4 = ''
         I8 = ''
      END
*
      RES = ''
      RES<-1> = '<table ' : TBL.OPTIONS : '>'
*
      N.CELLS = DCOUNT(C.DATA,AM)
      T = DCOUNT(C.OPTS,AM)
      IF T > N.CELLS THEN N.CELLS = T
*
      N.ROWS = INT( ( N.CELLS + N.COLS - 1 ) / N.COLS )
*
      FOR ROW = 1 TO N.ROWS
         RES<-1> = I4 : '<tr>'
         FOR COL = 1 TO N.COLS
            IF V.FLG THEN
               CELL = ROW + ( COL - 1 ) * N.ROWS
            END ELSE
               CELL = COL + ( ROW - 1 ) * N.COLS
            END
            T = ''
            IF ROW = 1 THEN
               IF C.WID<COL> <> '' THEN
                  T = ' width="' : C.WID<COL> : '"'
               END
            END
            RES<-1> = I8 : '<td' : T : ' ' : C.OPTS<CELL> : '>' : C.DATA<CELL> : '</td>'
         NEXT COL
         RES<-1> = I4 : '</tr>'
      NEXT ROW
*
      RES<-1> = '</table>'
*
      RETURN
   END
