Please you fix error at Line24?
I do not understand, can you fix at line24. Where You close first-for and Second-For?
Why you use both row=row+1? You see at line23 and line31.
OK. Attached is revised lisp and your original drawing. The drawing contains a table
#region rh_amt
(defun rh_AMT
( spc title lst ipt
/ t_obj rows cols row cell rdat
) /*c2s:
if (!ipt
) ipt
=getpoint("\nSelect Table Insertion Point: "); t_obj=vla.addtable(spc,vlax.3d_point(ipt),
vla.put_regeneratetablesuppressed(t_obj,vlax_true);
vla.settextstyle(t_obj,acDataRow+acHeaderRow+acTitleRow,"TOPOCAD");
vlax.invoke
(t_obj,
read("setrowheight"),
0,
10.0); vlax.invoke
(t_obj,
read("setcelltextheight"),
0,
0,
2.5); vlax.invoke
(t_obj,
read("settext"),
0,
0,title
); rows
=vlax.get
(t_obj,
read("rows"))-2),
cols
=vlax.get
(t_obj,
read("columns"))-1),
for(row=1;row<rows;row=row+1)
{ for
(rdat
=nth(row
-1),lst
),cell
=0;cell<cols;cell=cell+1) { vlax.invoke
(t_obj,
read("setcelltextheight"),row,cell,
2.5); vlax.invoke
(t_obj,
read("settext"),row,cell,
nth(cell,rdat
)); vlax.invoke
(t_obj,
read("setcellalignment"),row,cell,acMiddleCenter
); cell= (cell+1);
};
row= (row+1);
{ vlax.invoke
(t_obj,
read("setrowheight"),row,
6.0); vlax.invoke
(t_obj,
read("mergecells"),row,row,
0,cols
); vlax.invoke
(t_obj,
read("setcelltextheight"),row,
0,
2.5); vlax.invoke
(t_obj,
read("settext"),row,
0,
car(rdat
)); row= (row+1);
};
};
vla.put_regeneratetablesuppressed(t_obj, vlax_false);
*/
)
%include=vl_load_com
#endregion
There is no error in the lisp code. It works. I have no idea into which language you're trying to translate it? A for loop is not a direct substitute for a while loop, the work slightly differently. Since you are setting row=row+1 on line 16 I would assume that line 23 isn't needed.
The original had a while loop testing if row meets a condition i.e. it was less than (the number of rows minus 2), for that row must be incremented for each iteration, which also enables it to be used to extract the correct list from the data. The inside while loop is used to fill each cell in the row, so at the end of the outer while loop row is incremented and cell reset to 0 (zero). The data consists of a list of lists. Each list in the list has 3 items, except for the last 2 which only have 1 item.
The repeat 2 is to merge cells on the last 2 rows and place the correct single item data in that row, therefore row again needs to be incremented for each iteration.