1// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2// Copyright (C) INRIA
3//
4// Copyright (C) 2012 - 2016 - Scilab Enterprises
5//
6// This file is hereby licensed under the terms of the GNU GPL v2.0,
7// pursuant to article 5.3.4 of the CeCILL v.2.1.
8// This file was originally licensed under the terms of the CeCILL v2.1,
9// and continues to be available under such terms.
10// For more information, see the COPYING file which you should have received
11// along with this program.
12
13function %cblock_p(m)
14    n=size(definedfields(m),"*")
15    if n==1 then
16        mprintf(_("  (empty table)\n"))
17        return
18    end
19    txt=[];
20    for k=2:n
21        txt=[txt string(getfield(k,m))];
22    end
23    l=max(length(txt),"r");
24    n=size(txt,2);
25    for k=1:n
26        txt(:,k)=part(txt(:,k),1:l(k));
27    end
28
29    nlc=lines()
30    k1=1
31    while %t
32        L=cumsum(l(k1:$)+2)
33        k2=max(find(L<nlc(1)-3))
34        if k2==[] then k2=k1  ;else k2=k1-1+k2;end
35        t=emptystr(size(txt,1),1);
36        for i=k1:k2
37            t=t+txt(:,i)+"  ";
38        end
39        if k1==1&k2==n then  mprintf("%s\n","  "+t),break,end
40
41        if k1==k2 then
42            mprintf("%s\n",["Column "+string(k1);" ";"  "+t])
43        else
44            mprintf("%s\n",["Columns "+string(k1)+" to "+string(k2);" ";+"  "+t;" "])
45        end
46        if k2==n then break,end
47        k1=k2+1
48    end
49endfunction
50
51