function c=dsplay(in,out,s,d)
% dsplay 	- Used in display to display stream information in mass balance
% function c=dsplay(in,out,s,d)
%  Argument List:
%  Argument    Gives
%    in     the inlet stream numbers.
%    out    the exit stream numbers
%     s     the number of spaces for each flow.
%     d     the number of decimals to display flows.
% ex: cmix=dsplay([1 2],3,10,3)
% OKB

global ns cnms
lin=length(in)+1;
lout=length(out)+1;
if length(in)==1
   min=ns(in,:)';
   tin=charmx(in,s,0);
   sin=floor((s-5)/2);
else
   min=ns(in,:);
   min=[min;sum(min)]';
   tin=[charmx(in,s,0),'   Total'];
   tin=cext(tin,lin*s);
   sin=floor(((lin*s)-5)/2);
end
if length(out)==1
   mout=ns(out,:)';
   tout=charmx(out,s,0);
   sout=floor((s-6)/2);
else
   mout=ns(out,:);
   mout=[mout;sum(mout)]';
   tout=[charmx(out,s,0),'   Total'];
   tout=cext(tout,lout*s);
   sout=floor(((lout*s)-6)/2);
end
min=[min;csum(min)];
mout=[mout;csum(mout)];
inl=cext([cext(' ',sin),'Inlet'],length(tin));
cha=charmx(min,s,d);
cin=[inl;tin;cha];
ino=cext([cext(' ',sout),'Outlet'],length(tout));
cout=[ino;tout;charmx(mout,s,d)];
[nr,nc]=size(cnms);
if nc<8
   bl=blank(nr,8-nc);
   cnms=addcol(cnms,bl);
   nc=8;
end
bl=cext(' ',nc-6);
lft=[cext('Compound',nc);[bl,'Stream'];cnms;cext('Total',nc)];
mid=[nchar(' ',nr+3);nchar('|',nr+3)]';
c=addcol(lft,cin,mid,cout);
v=[1 2];
[nri,nc1]=size(min);
[nro,nco]=size(mout);
for k=1:nr
   if (abs(min(k,nc1))>eps)|(abs(mout(k,nco))>eps)
       v=[v,k+2];
   end
end
c=c([v,nr+3],:);


