// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab // Copyright (C) INRIA // // This file must be used under the terms of the CeCILL. // This source file is licensed as described in the file COPYING, which // you should have received as part of this distribution. The terms // are also available at // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt function s=%st_e(varargin) //extraction from struct w=varargin($); if type(varargin(1))==4 then varargin(1)=find(varargin(1)); // Bug #7244 end if type(varargin(1))==15 //x(i,j,k).f or x.f(i,j,k) index=varargin($-1); if type(index($))==10 then //x(i,j,k).f f=index($); //ijk=list2vec(index(1)); [indx,I]=convertindex(double(w.dims),index(1)(:)); // I<->ijk all_fields=getfield(1,w);all_fields=all_fields(3:$); fieldnum=find(f==all_fields); if fieldnum==[] then error(msprintf(gettext("%s: Invalid field name.\n"),"%st_e")); end good_list=getfield(2+fieldnum,w); if size(I,"*")==1 then s=good_list(I) //list(good_list(I)) ? else s=list(); for kk=1:size(I,"*") s(kk)=good_list(I(kk));end end return; else //x.f(i,j,k) f=index(1); li=w(f); [indx,I]=convertindex(double(w.dims),index($)(:)); s=li(I); return; end end if type(varargin(1))==10 then //field x.f fields=getfield(1,w);nu=find(fields(3:$)==varargin(1)); if nu==[] then error(msprintf(gettext("%s: Wrong value for input argument #%d: not a valid field name.\n"),"%st_e",1));return; end s=getfield(nu+2,w); if prod(getfield(2,w))==1 then s=s(1);end return; end //substruct x(i,j,k...) nind=size(varargin)-1 dims1=double(w.dims) if nind[]&dims($)==1 then dims($)=[],end select size(dims,"*") case 0 then dims=[1,1] case 1 then dims=[dims,1] else dims=matrix(dims,1,-1) end s=mlist(getfield(1,w),int32(dims)); //s=mlist(getfield(1,w),int32(indx)); sz=size(getfield(1,w),"*"); for k=3:sz ww=getfield(k,w); if type(ww)~=15 then ww=list(ww);end //S(2,3).f1=12 -> k=3;I=6;ww(I)=12;s=mlist(["st","dims","f1"],int32([1;1])); if prod(dims)==1 then setfield(k,ww(I),s); elseif prod(dims)>1 then setfield(k,list(ww(I)),s); end end endfunction