// déclaration variables
var Lignes,LCol:TStringList;
i,j,l,MaxCol,Col,LastCol:integer;
css,css2,css2for:string;
Ligne,cell:string;
begin

// css appliquée à l'ensemble du tableau
css := GetParam('css','');

// css appliqué aux col/row paire
css2 := GetParam('css2','');
css2for := GetParam('css2For','row');

LCol := TStringList.create;
Lignes := TStringList.create;
Lignes.Text := GetParam('Text','');
// déterminer le nombre maximal de colonne,tabulation = 1 colonne
MaxCol := 0;
for i:=0 to lignes.count-1 do
begin
Col := 0;
Ligne := Lignes.strings[i];
// parcourir la ligne pour déterminer le nombre de tabulation
l := length(ligne);
for j:=1 to l do
if GetChar(ligne,j)=#9 then
begin
LastCol := j;
if LCOl.count<=Col then LCol.add(IntToStr(j))
else begin
if strtoint(LCol.strings[col])<j then LCol.strings[col] := inttostr(j);
end;
col := col+1;
end;


if LCOl.count<=Col+1 then LCol.add(IntToStr(length(ligne)))
else begin
if strtoint(LCol.strings[col+1])<length(ligne) then LCol.strings[col+1] := inttostr(ligne);
end;

if Col>MaxCol then
begin
MaxCol := Col;
end;
end;



if Condition('_HTML_') then
begin
write('<<WEB($html:+)>>');

write('<table');
if css<>'' then write(' class="'+css+'"');
writeln('>');

for i:=0 to lignes.count-1 do
begin
col := maxcol;
ligne := lignes.strings[i];
write('<tr');
// si row appliqué css2 aux lignes paires
if (css2for='row')and(css2<>'') then
if (i mod 2)=0 then write(' class="'+css2+'"');
write('>');
while col>-1 do
begin
j := pos(#9,ligne);
if j>0 then
begin
cell := copy(ligne,1,j-1);
ligne := copy(ligne,j+1,length(ligne));
end else begin
if ligne<>'' then
begin
cell:=ligne;
ligne := '';
end else cell := '';
end;
write('<td');
if (css2for='col')and(css2<>'') then
if (col mod 2)<>0 then write(' class="'+css2+'"');
write('>'+cell+'</td>');
col := col-1;
end;
writeln('</tr>');
end;

writeln('</table>');

write('<<WEB($html:-)>>');
end else

begin
write('<<TABLE.')>>+css+<<FNT(STRING.-,-,-,-:':')>>);
col := <<FNT(NUMBER.-,-,-,-:0)>>;
<<FNT(KEYWORD.-,-,-,-:for)>> i:=<<FNT(NUMBER.-,-,-,-:0)>> to lcol.count-<<FNT(NUMBER.-,-,-,-:1)>> <<FNT(KEYWORD.-,-,-,-:do)>>
<<FNT(KEYWORD.-,-,-,-:begin)>>
col := col + StrToInt(LCol.strings[i])*<<FNT(NUMBER.-,-,-,-:16)>>;
<<FNT(KEYWORD.-,-,-,-:write)>>(inttostr(col)+<<FNT(STRING.-,-,-,-:',')>>);
<<FNT(KEYWORD.-,-,-,-:end)>>;
writeln(<<FNT(STRING.-,-,-,-:'!,Left,,@Top,>>'
);
for i:=0 to lignes.count-1 do
begin
col := maxcol;
ligne := lignes.strings[i];
write('<<TR.')>>);
<<FNT(COMMENT.--,-,-,-:// si row appliqué css2 aux lignes paires)>>
<<FNT(KEYWORD.-,-,-,-:if)>> css2for=<<FNT(STRING.-,-,-,-:'row')>> <<FNT(KEYWORD.-,-,-,-:then)>>
<<FNT(KEYWORD.-,-,-,-:if)>> (i <<FNT(KEYWORD.-,-,-,-:mod)>> <<FNT(NUMBER.-,-,-,-:2)>>)=<<FNT(NUMBER.-,-,-,-:0)>> <<FNT(KEYWORD.-,-,-,-:then)>> <<FNT(KEYWORD.-,-,-,-:write)>>(css2);

<<FNT(KEYWORD.-,-,-,-:write)>>(<<FNT(STRING.-,-,-,-:':>>'
);
while col>-1 do
begin
j := pos(#9,ligne);
if j>0 then
begin
cell := copy(ligne,1,j-1);
ligne := copy(ligne,j+1,length(ligne));
end else begin
if ligne<>'' then
begin
cell:=ligne;
ligne := '';
end else cell := '';
end;
write('<<TD')>>);
<<FNT(KEYWORD.-,-,-,-:if)>> css2for=<<FNT(STRING.-,-,-,-:'col')>> <<FNT(KEYWORD.-,-,-,-:then)>>
<<FNT(KEYWORD.-,-,-,-:if)>> (col <<FNT(KEYWORD.-,-,-,-:mod)>> <<FNT(NUMBER.-,-,-,-:2)>>)<><<FNT(NUMBER.-,-,-,-:0)>> <<FNT(KEYWORD.-,-,-,-:then)>> <<FNT(KEYWORD.-,-,-,-:write)>>(<<FNT(STRING.-,-,-,-:'.')>>+css2);
<<FNT(KEYWORD.-,-,-,-:write)>>(<<FNT(STRING.-,-,-,-:': 0,0>>'
+cell+'<</TD>>');
col := col-1;
end;
writeln('<</TR>>');
end;

writeln('<</TABLE>>');


Lignes.free;
LCol.free;
end;
end.

Sommaire