From: <sch...@us...> - 2010-05-21 10:42:29
|
Revision: 7328 http://octave.svn.sourceforge.net/octave/?rev=7328&view=rev Author: schloegl Date: 2010-05-21 10:42:23 +0000 (Fri, 21 May 2010) Log Message: ----------- replace obsolete function STRUCT_CONTAINS with ISFIELD Modified Paths: -------------- trunk/octave-forge/extra/pdb/inst/read_pdb.m trunk/octave-forge/extra/pdb/inst/write_pdb.m trunk/octave-forge/main/miscellaneous/inst/read_options.m trunk/octave-forge/main/miscellaneous/inst/temp_name.m trunk/octave-forge/main/vrml/inst/vmesh.m trunk/octave-forge/main/vrml/inst/vrml_Background.m trunk/octave-forge/main/vrml/inst/vrml_DirectionalLight.m Modified: trunk/octave-forge/extra/pdb/inst/read_pdb.m =================================================================== --- trunk/octave-forge/extra/pdb/inst/read_pdb.m 2010-05-21 10:01:35 UTC (rev 7327) +++ trunk/octave-forge/extra/pdb/inst/read_pdb.m 2010-05-21 10:42:23 UTC (rev 7328) @@ -54,11 +54,11 @@ global elements_struct; load("-force", file_in_loadpath("elements_struct.mat")); -if(struct_contains(p, "atomname")) +if(isfield(p, "atomname")) p.az = atomnames_to_z(p.atomname); endif -if(struct_contains(p, "hetname")) +if(isfield(p, "hetname")) p.hetz = atomnames_to_z(p.hetname); endif Modified: trunk/octave-forge/extra/pdb/inst/write_pdb.m =================================================================== --- trunk/octave-forge/extra/pdb/inst/write_pdb.m 2010-05-21 10:01:35 UTC (rev 7327) +++ trunk/octave-forge/extra/pdb/inst/write_pdb.m 2010-05-21 10:42:23 UTC (rev 7328) @@ -24,7 +24,7 @@ function write_pdb(p, fname, varargin) -if(!isstruct(p)) # || !struct_contains(p, "acoord")) +if(!isstruct(p)) # || !isfield(p, "acoord")) error("p must be a pdb struct"); endif @@ -44,13 +44,13 @@ # Print the Title Section -if( struct_contains(p, "classification") || struct_contains(p, "idcode") ) - if struct_contains(p, "classification") +if( isfield(p, "classification") || isfield(p, "idcode") ) + if isfield(p, "classification") classification = p.classification; else classification = "Unknown"; endif - if(struct_contains(p, "idcode")) + if(isfield(p, "idcode")) idcode = p.idcode; else idcode = "N/A "; @@ -65,7 +65,7 @@ # Print the Primary Structure Section numres = 0; -if(struct_contains(p, "seqres")) +if(isfield(p, "seqres")) numres = size(p.seqres, 1); j = 1; i = 1; @@ -104,24 +104,24 @@ # Print the Crystallographic and Coordinate Transformation Section -if( struct_contains(p, "cellsize") || struct_contains(p, "cellangl") \ - || struct_contains(p, "sgroup") || struct_contains(p, "z") ) - if(struct_contains(p, "cellsize")) +if( isfield(p, "cellsize") || isfield(p, "cellangl") \ + || isfield(p, "sgroup") || isfield(p, "z") ) + if(isfield(p, "cellsize")) cellsize = p.cellsize; else cellsize = zeros(3,1); endif - if(struct_contains(p, "cellangl")) + if(isfield(p, "cellangl")) cellangl = p.cellangl; else cellangl = zeros(3,1); endif - if(struct_contains(p, "sgroup")) + if(isfield(p, "sgroup")) sgroup = p.sgroup; else sgroup = "N/A"; endif - if(struct_contains(p, "z")) + if(isfield(p, "z")) z = p.z; else z = 0; @@ -149,13 +149,13 @@ #buf(80) = "\n"; #fprintf(f, "%s", buf); -if( struct_contains(p, "scalem") || struct_contains(p, "scalev") ) - if(struct_contains(p, "scalem")) +if( isfield(p, "scalem") || isfield(p, "scalev") ) + if(isfield(p, "scalem")) scalem = p.scalem; else scalem = eye(3); endif - if(struct_contains(p, "scalev")) + if(isfield(p, "scalev")) scalev = p.scalev; else scalev = zeros(3,1); @@ -183,33 +183,33 @@ endif # if(!quick) serialn = 0; -if(struct_contains(p, "acoord")) +if(isfield(p, "acoord")) natoms = size(p.acoord, 1); - if(struct_contains(p, "atomname")) + if(isfield(p, "atomname")) atomname = toupper(p.atomname); else for i = 1:natoms, atomname(i, :) = " "; endfor endif - if(struct_contains(p, "aresname")) + if(isfield(p, "aresname")) aresname = toupper(p.aresname); else for i = 1:natoms, aresname(i, :) = " "; endfor endif - if(struct_contains(p, "aresseq")) + if(isfield(p, "aresseq")) aresseq = p.aresseq; else aresseq = ones(natoms, 1); endif - if(struct_contains(p, "aoccupancy")) + if(isfield(p, "aoccupancy")) aoccupancy = p.aoccupancy; else aoccupancy = ones(natoms, 1); endif - if(struct_contains(p, "atempfactor")) + if(isfield(p, "atempfactor")) atempfactor = p.atempfactor; else atempfactor = zeros(natoms, 1); @@ -265,33 +265,33 @@ fprintf(f, "%s", buf); endif -if(struct_contains(p,"hetcoord")) +if(isfield(p,"hetcoord")) nhet = size(p.hetcoord, 1); - if(struct_contains(p, "hetname")) + if(isfield(p, "hetname")) hetname = toupper(p.hetname); else for i = 1:nhet hetname(i, :) = " "; endfor endif - if(struct_contains(p, "hetresname")) + if(isfield(p, "hetresname")) hetresname = toupper(p.hetresname); else for i = 1:nhet, hetresname(i, :) = " "; endfor endif - if(struct_contains(p, "hetresseq")) + if(isfield(p, "hetresseq")) hetresseq = p.hetresseq; else hetresseq = ones(nhet, 1); endif - if(struct_contains(p, "hetoccupancy")) + if(isfield(p, "hetoccupancy")) hetoccupancy = p.hetoccupancy; else hetoccupancy = ones(nhet, 1); endif - if(struct_contains(p, "hettempfactor")) + if(isfield(p, "hettempfactor")) hettempfactor = p.hettempfactor; else hettempfactor = zeros(nhet, 1); Modified: trunk/octave-forge/main/miscellaneous/inst/read_options.m =================================================================== --- trunk/octave-forge/main/miscellaneous/inst/read_options.m 2010-05-21 10:01:35 UTC (rev 7327) +++ trunk/octave-forge/main/miscellaneous/inst/read_options.m 2010-05-21 10:42:23 UTC (rev 7328) @@ -79,16 +79,17 @@ i=1; while i<nargs - if ! ischar (tmp = varargin{i++}), error ("non-string option"); end - if strcmp (tmp, "op0") , op0 = varargin{i++}; - elseif strcmp (tmp, "op1") , op1 = varargin{i++}; - elseif strcmp (tmp, "extra") , extra = varargin{i++}; - elseif strcmp (tmp, "default"), op = varargin{i++}; - elseif strcmp (tmp, "prefix") , prefix = varargin{i++}; - elseif strcmp (tmp, "nocase") , nocase = varargin{i++}; - elseif strcmp (tmp, "quiet") , quiet = varargin{i++}; - elseif strcmp (tmp, "skipnan"), skipnan = varargin{i++}; - elseif strcmp (tmp, "verbose"), verbose = varargin{i++}; + if ! ischar (tmp = varargin{i}), error ("non-string option"); end + i = i+1; + if strcmp (tmp, "op0") , op0 = varargin{i}; i=i+1; + elseif strcmp (tmp, "op1") , op1 = varargin{i}; i=i+1; + elseif strcmp (tmp, "extra") , extra = varargin{i}; i=i+1; + elseif strcmp (tmp, "default"), op = varargin{i}; i=i+1; + elseif strcmp (tmp, "prefix") , prefix = varargin{i}; i=i+1; + elseif strcmp (tmp, "nocase") , nocase = varargin{i}; i=i+1; + elseif strcmp (tmp, "quiet") , quiet = varargin{i}; i=i+1; + elseif strcmp (tmp, "skipnan"), skipnan = varargin{i}; i=i+1; + elseif strcmp (tmp, "verbose"), verbose = varargin{i}; i=i+1; else error ("unknown option '%s' for option-reading function!",tmp); end @@ -109,7 +110,7 @@ end if length (extra) - lextra = lgrep (cellstr (split (extra, " "))); + lextra = lgrep (cellstr (strsplit (extra, " "))); else lextra = {}; end @@ -159,7 +160,7 @@ tmp = correct = ""; j = 0; for i = ii - fullen(++j) = spi(find (spi > i)(1))-i ; + fullen(++j) = spi(find (spi > i,1))-i ; tmp = [tmp,"', '",opts(i:i+fullen(j)-1)]; end tmp = tmp(5:length(tmp)); @@ -168,13 +169,13 @@ ((min (fullen) != length(name)) && ! prefix) , error ("ambiguous option '%s'. Could be '%s'",oname,tmp); end - j = find (fullen == min (fullen))(1); + j = find (fullen == min (fullen), 1); ii = ii(j); end # Full name of option (w/ correct case) - fullname = opts_orig(ii:spi(find (spi > ii)(1))-1); + fullname = opts_orig(ii:spi(find (spi > ii, 1))-1); if ii < iend if verbose, printf ("read_options : found boolean '%s'\n",fullname); end op.(fullname) = 1; @@ -184,7 +185,7 @@ tmp = args{++nread}; if verbose, printf ("read_options : size is %i x %i\n",size(tmp)); end if !isnumeric (tmp) || !all (isnan (tmp(:))) || \ - !struct_contains (op, fullname) + !isfield (op, fullname) op.(fullname) = tmp; else if verbose, printf ("read_options : ignoring nan\n"); end Modified: trunk/octave-forge/main/miscellaneous/inst/temp_name.m =================================================================== --- trunk/octave-forge/main/miscellaneous/inst/temp_name.m 2010-05-21 10:01:35 UTC (rev 7327) +++ trunk/octave-forge/main/miscellaneous/inst/temp_name.m 2010-05-21 10:42:23 UTC (rev 7328) @@ -38,7 +38,7 @@ if nargin<2, quick = 1; end if quick - if ! struct_contains (cnt, rootname) + if ! isfield (cnt, rootname) cnt.(rootname) = 0; c = 0 ; else @@ -57,4 +57,4 @@ if quick cnt.(rootname) = c ; -end \ No newline at end of file +end Modified: trunk/octave-forge/main/vrml/inst/vmesh.m =================================================================== --- trunk/octave-forge/main/vrml/inst/vmesh.m 2010-05-21 10:01:35 UTC (rev 7327) +++ trunk/octave-forge/main/vrml/inst/vmesh.m 2010-05-21 10:42:23 UTC (rev 7328) @@ -1,3 +1,4 @@ + ## Copyright (C) 2002-2009 Etienne Grossmann. All rights reserved. ## ## This program is free software; you can redistribute it and/or modify it @@ -125,9 +126,8 @@ "zgray","zrb","zcol"}; for i = 1:length(all_surf_opts) - ## optname = nth (all_surf_opts, i); optname = all_surf_opts{i}; - if struct_contains (opts, optname) + if isfield (opts, optname) ## surf_args = append (surf_args, list (optname)); surf_args{length(surf_args)+1} = optname; if index (op1,[" ",optname," "]) @@ -163,7 +163,7 @@ pts = [x(:)';y(:)';z(:)']; ii = find (all (isfinite (pts))); -pt2 = pts(:,ii); x2 = x(:)(ii); y2 = y(:)(ii); z2 = z(:)(ii); +pt2 = pts(:,ii); x2 = x(ii); y2 = y(ii); z2 = z(ii); ## Add a point light @@ -215,7 +215,7 @@ # Transpose colors if all (szlc == [3,nlev]), lcol = lcol'; # Single gray level - elseif nlc == 1 , lcol *= ones (nlev,3); + elseif nlc == 1 , lcol = lcol * ones (nlev,3); # nlev gray levels elseif nlc == nlev , lcol = lcol(:)*[1 1 1]; elseif nlc == 3 , lcol = ones(nlev,1)*lcol(:)'; @@ -274,3 +274,4 @@ endfunction + Modified: trunk/octave-forge/main/vrml/inst/vrml_Background.m =================================================================== --- trunk/octave-forge/main/vrml/inst/vrml_Background.m 2010-05-21 10:01:35 UTC (rev 7327) +++ trunk/octave-forge/main/vrml/inst/vrml_Background.m 2010-05-21 10:42:23 UTC (rev 7328) @@ -56,7 +56,7 @@ body = ""; for [val,key] = hash, - if struct_contains (opts, key) + if isfield (opts, key) n = opts.(key); if (n == 0) if (ischar(val)) Modified: trunk/octave-forge/main/vrml/inst/vrml_DirectionalLight.m =================================================================== --- trunk/octave-forge/main/vrml/inst/vrml_DirectionalLight.m 2010-05-21 10:01:35 UTC (rev 7327) +++ trunk/octave-forge/main/vrml/inst/vrml_DirectionalLight.m 2010-05-21 10:42:23 UTC (rev 7328) @@ -19,12 +19,11 @@ function s = vrml_DirectionalLight (varargin) # pos 2.1.39 -hash = struct (); # pos 2.1.39 +hash = struct (); +for k=1:2:nargin, + hash = setfield(hash,varargin{k:k+1}); +end - -if nargin, hash = setfield(hash,varargin{:}); end # pos 2.1.39 -## hash = rmfield (hash, "dummy"); - tpl = struct ("ambientIntensity", "%8.3f",\ "intensity", "%8.3f",\ "direction", "%8.3f",\ @@ -37,7 +36,7 @@ if !(isnumeric(val) && isnan (val)), # Check validity of field - if ! struct_contains (tpl, key) + if !isfield (tpl, key) error (sprintf ("vrml_PointLight : unknown field '%s'",key)); end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |