# HG changeset patch # User Rik # Date 1373403845 25200 # Node ID e39f00a32dc7935dbc053037acea14608b21fe7d # Parent c55df4e5e216d24d06428b26e5339cbbeb74abb0 maint: Use parentheses around condition for switch(),while(),if() statements. * libinterp/corefcn/dirfns.cc, libinterp/octave-value/ov-fcn-handle.cc, liboctave/array/Sparse.cc, scripts/image/rgb2ind.m, scripts/io/importdata.m, scripts/io/strread.m, scripts/optimization/fminbnd.m, scripts/optimization/sqp.m, scripts/plot/graphics_toolkit.m, scripts/plot/hdl2struct.m, scripts/plot/legend.m, scripts/plot/print.m, scripts/plot/printd.m, scripts/plot/private/__contour__.m, scripts/plot/private/__go_draw_axes__.m, scripts/plot/struct2hdl.m, scripts/polynomial/polyeig.m, scripts/sparse/bicg.m, scripts/specfun/ellipke.m, scripts/special-matrix/gallery.m, scripts/ui/errordlg.m, scripts/ui/helpdlg.m, scripts/ui/inputdlg.m, scripts/ui/listdlg.m, scripts/ui/questdlg.m, scripts/ui/warndlg.m: Use parentheses around condition for switch(),while(),if() statements. diff -r c55df4e5e216 -r e39f00a32dc7 libinterp/corefcn/dirfns.cc --- a/libinterp/corefcn/dirfns.cc Tue Jul 09 12:22:33 2013 -0700 +++ b/libinterp/corefcn/dirfns.cc Tue Jul 09 14:04:05 2013 -0700 @@ -628,7 +628,7 @@ %! if (mkdir (tmpdir)) %! cwd = pwd; %! cd (tmpdir); -%! if strcmp (canonicalize_file_name (pwd), canonicalize_file_name (tmpdir)) +%! if (strcmp (canonicalize_file_name (pwd), canonicalize_file_name (tmpdir))) %! a = 0; %! for n = 1:5 %! save (filename{n}, "a"); diff -r c55df4e5e216 -r e39f00a32dc7 libinterp/octave-value/ov-fcn-handle.cc --- a/libinterp/octave-value/ov-fcn-handle.cc Tue Jul 09 12:22:33 2013 -0700 +++ b/libinterp/octave-value/ov-fcn-handle.cc Tue Jul 09 14:04:05 2013 -0700 @@ -1329,14 +1329,14 @@ /* %!function fcn_handle_save_recurse (n, mode, nm, f2, g2, hm2, hdld2, hbi2) -%! if n == 0 +%! if (n == 0) %! save (mode, nm, "f2", "g2", "hm2", "hdld2", "hbi2"); %! else %! fcn_handle_save_recurse (n - 1, mode, nm, f2, g2, hm2, hdld2, hbi2); %! endif %!endfunction %!function [f2, g2, hm2, hdld2, hbi2] = fcn_handle_load_recurse (n, nm) -%! if n == 0 +%! if (n == 0) %! load (nm) %! else %! [f2, g2, hm2, hdld2, hbi2] = fcn_handle_load_recurse (n - 1, nm); diff -r c55df4e5e216 -r e39f00a32dc7 liboctave/array/Sparse.cc --- a/liboctave/array/Sparse.cc Tue Jul 09 12:22:33 2013 -0700 +++ b/liboctave/array/Sparse.cc Tue Jul 09 14:04:05 2013 -0700 @@ -2623,7 +2623,7 @@ * %!function x = set_slice (x, dim, slice, arg) -%! switch dim +%! switch (dim) %! case 11 %! x(slice) = 2; %! case 21 @@ -2636,7 +2636,7 @@ %!endfunction %!function x = set_slice2 (x, dim, slice) -%! switch dim +%! switch (dim) %! case 11 %! x(slice) = 2 * ones (size (slice)); %! case 21 diff -r c55df4e5e216 -r e39f00a32dc7 scripts/image/rgb2ind.m --- a/scripts/image/rgb2ind.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/image/rgb2ind.m Tue Jul 09 14:04:05 2013 -0700 @@ -66,7 +66,7 @@ else ## Test for dither_option, by checking if the final input is a string - if ischar (varargin{end}) + if (ischar (varargin{end})) dither_option = varargin{end}; dither_check = true; else @@ -143,14 +143,14 @@ ## If image is an ND array, convert it to a tiled 2D image ## before processing it with Graphicsmagick - if numel (sz)>3 + if (numel (sz) > 3) rgb = reshape (rgb, [prod(sz(1:end-2)), sz(end-1), 3]); end ## Prepare the Graphicsmagick dithering option - if strcmp (dither_option, "nodither") + if (strcmp (dither_option, "nodither")) ditherstr = "+dither"; - elseif strcmp (dither_option, "dither") + elseif (strcmp (dither_option, "dither")) ditherstr = "-dither"; endif diff -r c55df4e5e216 -r e39f00a32dc7 scripts/io/importdata.m --- a/scripts/io/importdata.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/io/importdata.m Tue Jul 09 14:04:05 2013 -0700 @@ -120,7 +120,7 @@ ## Make sure file extension is in lower case. fileExt = lower (fileExt); - switch fileExt + switch (fileExt) case {".au", ".snd"} error ("importdata: not implemented for file format %s", fileExt); case ".avi" diff -r c55df4e5e216 -r e39f00a32dc7 scripts/io/strread.m --- a/scripts/io/strread.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/io/strread.m Tue Jul 09 14:04:05 2013 -0700 @@ -479,7 +479,7 @@ iwrd = 1; iwrdp = 0; iwrdl = length (words{1}); fwptr = zeros (1, numel (fmt_words)); ii = 1; - while ii <= numel (fmt_words) + while (ii <= numel (fmt_words)) nxt_wrd = 0; ## Keep track of which words nr. every fmt_words{} is (starts) in. @@ -679,7 +679,7 @@ ## Map to format ## FIXME - add support for formats like "<%s>", "%[a-zA-Z]" ## Someone with regexp experience is needed. - switch fmt_words{m}(1:min (2, length (fmt_words{m}))) + switch (fmt_words{m}(1:min (2, length (fmt_words{m})))) case "%s" if (pad_out) data(end+1:num_lines) = {""}; @@ -706,7 +706,7 @@ ew = regexp (fmt_words{m}, '[nfudsq]') - 1; nfmt = ostrsplit (fmt_words{m}(2:ew), "."); swidth = str2double (nfmt{1}); - switch fmt_words{m}(ew+1) + switch (fmt_words{m}(ew+1)) case {"d", "u", "f", "n"} n = cellfun ("isempty", data); ### FIXME - erroneously formatted data lead to NaN, not an error diff -r c55df4e5e216 -r e39f00a32dc7 scripts/optimization/fminbnd.m --- a/scripts/optimization/fminbnd.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/optimization/fminbnd.m Tue Jul 09 14:04:05 2013 -0700 @@ -210,7 +210,7 @@ iter(1).procedure = "initial"; ## Handle the "Display" option - switch displ + switch (displ) case "iter" print_formatted_table (iter); print_exit_msg (info, struct("TolX", tolx, "fx", fval)); @@ -259,7 +259,7 @@ ## Print either a success termination message or bad news function print_exit_msg (info, opt=struct()) printf (""); - switch info + switch (info) case 1 printf ("Optimization terminated:\n"); printf (" the current x satisfies the termination criteria using OPTIONS.TolX of %e\n", opt.TolX); diff -r c55df4e5e216 -r e39f00a32dc7 scripts/optimization/sqp.m --- a/scripts/optimization/sqp.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/optimization/sqp.m Tue Jul 09 14:04:05 2013 -0700 @@ -261,7 +261,7 @@ ## constraint inequality function only without any bounds ci_grd = @ (x) fd_ci_jac (x, globals.cifcn); if (iscell (cif)) - switch length (cif) + switch (length (cif)) case {1} ci_fun = cif{1}; case {2} diff -r c55df4e5e216 -r e39f00a32dc7 scripts/plot/graphics_toolkit.m --- a/scripts/plot/graphics_toolkit.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/plot/graphics_toolkit.m Tue Jul 09 14:04:05 2013 -0700 @@ -101,7 +101,7 @@ %!testif HAVE_FLTK %! old_toolkit = graphics_toolkit (); -%! switch old_toolkit +%! switch (old_toolkit) %! case {"gnuplot"} %! new_toolkit = "fltk"; %! otherwise diff -r c55df4e5e216 -r e39f00a32dc7 scripts/plot/hdl2struct.m --- a/scripts/plot/hdl2struct.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/plot/hdl2struct.m Tue Jul 09 14:04:05 2013 -0700 @@ -146,7 +146,7 @@ nflds = length (fields); ii = 0; - while nflds + while (nflds) prop = fields{nflds}; val = obj.(fields{nflds}); ii++; diff -r c55df4e5e216 -r e39f00a32dc7 scripts/plot/legend.m --- a/scripts/plot/legend.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/plot/legend.m Tue Jul 09 14:04:05 2013 -0700 @@ -1007,7 +1007,7 @@ outerposition = get (h, "unmodified_axes_outerposition"); units = get (hax, "units"); set (hax, "units", "points"); - switch get (hax, "activepositionproperty") + switch (get (hax, "activepositionproperty")) case "position" set (hax, "outerposition", outerposition); set (hax, "position", position); diff -r c55df4e5e216 -r e39f00a32dc7 scripts/plot/print.m --- a/scripts/plot/print.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/plot/print.m Tue Jul 09 14:04:05 2013 -0700 @@ -495,7 +495,7 @@ if (opts.tight_flag) cmd = "--copy --bbox"; elseif (! isempty (opts.preview)) - switch opts.preview + switch (opts.preview) case "tiff" cmd = sprintf ("--add-%s-preview --device tiffg3", opts.preview); case {"tiff6u", "tiff6p", "metafile"} @@ -617,7 +617,7 @@ opts.name = opts.name(1:n-1); endif latexfile = strcat (opts.name, ".tex"); - switch opts.devopt + switch (opts.devopt) case {"pdflatexstandalone"} packages = "\\usepackage{graphicx,color}"; graphicsfile = strcat (opts.name, "-inc.pdf"); diff -r c55df4e5e216 -r e39f00a32dc7 scripts/plot/printd.m --- a/scripts/plot/printd.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/plot/printd.m Tue Jul 09 14:04:05 2013 -0700 @@ -51,7 +51,7 @@ ## It seems best to only use convert for image output. Its ps and pdf ## are badly rendered. opt = lower (opt); - switch opt + switch (opt) case {"pdf"} enscr = sprintf ( "enscript --no-header -o %s.ps %s ; ps2pdf %s.ps %s.pdf; mv %s.pdf %s;exit",... diff -r c55df4e5e216 -r e39f00a32dc7 scripts/plot/private/__contour__.m --- a/scripts/plot/private/__contour__.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/plot/private/__contour__.m Tue Jul 09 14:04:05 2013 -0700 @@ -444,7 +444,7 @@ delete (get (h, "children")); - switch prop + switch (prop) case "levellist" set (h, "levellistmode", "manual") case "levelstep" diff -r c55df4e5e216 -r e39f00a32dc7 scripts/plot/private/__go_draw_axes__.m --- a/scripts/plot/private/__go_draw_axes__.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/plot/private/__go_draw_axes__.m Tue Jul 09 14:04:05 2013 -0700 @@ -1329,7 +1329,7 @@ else num_lines = numel (obj.string); endif - switch valign + switch (valign) ## Text offset in characters. This relies on gnuplot for font metrics. case "top" dy = -0.5; diff -r c55df4e5e216 -r e39f00a32dc7 scripts/plot/struct2hdl.m --- a/scripts/plot/struct2hdl.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/plot/struct2hdl.m Tue Jul 09 14:04:05 2013 -0700 @@ -417,7 +417,7 @@ xudata = s.properties.xudata; udata = s.properties.udata; - switch form + switch (form) case "xerr" h = errorbar (xdata, ydata, xldata, xudata, ">"); case "yerr" diff -r c55df4e5e216 -r e39f00a32dc7 scripts/polynomial/polyeig.m --- a/scripts/polynomial/polyeig.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/polynomial/polyeig.m Tue Jul 09 14:04:05 2013 -0700 @@ -46,13 +46,13 @@ n = zeros (1, nin); for cnt = 1 : nin - if ! ( issquare (varargin{cnt}) ) + if (! issquare (varargin{cnt})) error ("polyeig: coefficients must be square matrices"); endif n(cnt) = size (varargin{cnt}, 1); endfor - if numel (unique (n)) > 1 + if (numel (unique (n)) > 1) error ("polyeig: coefficients must have the same dimensions"); endif n = unique (n); diff -r c55df4e5e216 -r e39f00a32dc7 scripts/sparse/bicg.m --- a/scripts/sparse/bicg.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/sparse/bicg.m Tue Jul 09 14:04:05 2013 -0700 @@ -233,7 +233,7 @@ %! assert (x, ones (size (b)), 1e-7); %!function y = afun (x, t, a) -%! switch t +%! switch (t) %! case "notransp" %! y = a * x; %! case "transp" diff -r c55df4e5e216 -r e39f00a32dc7 scripts/specfun/ellipke.m --- a/scripts/specfun/ellipke.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/specfun/ellipke.m Tue Jul 09 14:04:05 2013 -0700 @@ -47,10 +47,10 @@ k = e = zeros (size (m)); m = m(:); - if any (!isreal (m)) + if (any (!isreal (m))) error ("ellipke must have real m"); endif - if any (m > 1) + if (any (m > 1)) error ("ellipke must have m <= 1"); endif @@ -119,7 +119,7 @@ %! 1.1047747327040733261; %! 1.0159935450252239356; %! 1.0 ]; -%! if k(7)==Inf, k(7)=0; endif; +%! if (k(7)==Inf), k(7)=0; endif; %! assert (k, k_exp, 8*eps); %! assert (e, e_exp, 8*eps); diff -r c55df4e5e216 -r e39f00a32dc7 scripts/special-matrix/gallery.m --- a/scripts/special-matrix/gallery.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/special-matrix/gallery.m Tue Jul 09 14:04:05 2013 -0700 @@ -1315,7 +1315,7 @@ x = x(:); y = y(:); - ## On next line, z = x'; A = z(ones(n,1),:) would be more efficient. + ## FIXME: On next line, z = x'; A = z(ones(n,1),:) would be more efficient. A = ones (n, 1) * x'; for j = 2:n A(1:j-1,j) = y(1:j-1); @@ -1503,16 +1503,16 @@ if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for lauchli matrix."); elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n) - error("gallery: N must be an integer for lauchli matrix.") + error ("gallery: N must be an integer for lauchli matrix.") elseif (! isscalar (mu)) - error("gallery: MU must be a scalar for lauchli matrix.") + error ("gallery: MU must be a scalar for lauchli matrix.") endif - A = (1:n)'*ones(1,n); - A = abs(A - A'); + A = (1:n)'*ones (1,n); + A = abs (A - A'); A = rho .^ A; - if imag(rho) - A = conj(tril(A,-1)) + triu(A); + if (imag (rho)) + A = conj (tril (A,-1)) + triu (A); endif endfunction @@ -1928,7 +1928,7 @@ a(1) = 2*w; a(2:n) = sin (2*pi*w*(1:n-1)) ./ (pi*(1:n-1)); - A = toeplitz(a); + A = toeplitz (a); endfunction function H = randhess (x) @@ -2252,8 +2252,8 @@ error ("gallery: K must be a numeric scalar for smoke matrix."); endif - w = exp(2*pi*i/n); - A = diag( [w.^(1:n-1) 1] ) + diag(ones(n-1,1),1); + w = exp (2*pi*i/n); + A = diag ( [w.^(1:n-1) 1] ) + diag (ones (n-1,1), 1); switch (k) case (0), A(n,1) = 1; diff -r c55df4e5e216 -r e39f00a32dc7 scripts/ui/errordlg.m --- a/scripts/ui/errordlg.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/ui/errordlg.m Tue Jul 09 14:04:05 2013 -0700 @@ -40,10 +40,11 @@ endfunction -%!demo -%! disp('- test errordlg with prompt only.'); -%! errordlg('Oops, an expected error occured'); %!demo -%! disp('- test errordlg with prompt and caption.'); -%! errordlg('Oops another error','This is a very long and informative caption'); +%! disp ('- test errordlg with prompt only.'); +%! errordlg ('Oops, an expected error occured'); + +%!demo +%! disp ('- test errordlg with prompt and caption.'); +%! errordlg ('Oops another error','This is a very long and informative caption'); diff -r c55df4e5e216 -r e39f00a32dc7 scripts/ui/helpdlg.m --- a/scripts/ui/helpdlg.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/ui/helpdlg.m Tue Jul 09 14:04:05 2013 -0700 @@ -40,10 +40,12 @@ endfunction -%!demo -%! disp('- test helpdlg with a help message only.'); -%! helpdlg("Below, you should see 3 lines:\nline #1\nline #2, and\nline #3."); %!demo -%! disp('- test helpdlg with help message and caption.'); -%! helpdlg('You should see a single line.','A help dialog'); +%! disp ('- test helpdlg with a help message only.'); +%! helpdlg ("Below, you should see 3 lines:\nline #1\nline #2, and\nline #3."); + +%!demo +%! disp ('- test helpdlg with help message and caption.'); +%! helpdlg ('You should see a single line.','A help dialog'); + diff -r c55df4e5e216 -r e39f00a32dc7 scripts/ui/inputdlg.m --- a/scripts/ui/inputdlg.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/ui/inputdlg.m Tue Jul 09 14:04:05 2013 -0700 @@ -142,64 +142,66 @@ endfunction -%!demo -%! disp('- test inputdlg with prompt and caption only.'); -%! prompt = {'Width','Height','Depth'}; -%! dims = inputdlg ( prompt, 'Enter Box Dimensions' ); -%! if isempty(dims) -%! helpdlg('Canceled by user', 'Information'); -%! else -%! volume = str2num(dims{1}) * str2num(dims{2}) * str2num(dims{3}); -%! surface = 2 * (str2num(dims{1}) * str2num(dims{2}) + ... -%! str2num(dims{2}) * str2num(dims{3}) + ... -%! str2num(dims{1}) * str2num(dims{3})); -%! helpdlg(sprintf('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); -%! end %!demo -%! disp('- test inputdlg with prescribed scalar (2 lines per text field) and defaults.'); -%! prompt = {'Width','Height','Depth'}; -%! default = {'1.1','2.2','3.3'}; -%! rc = 2; -%! dims = inputdlg ( prompt, 'Enter Box Dimensions',rc,default ); -%! if isempty(dims) -%! helpdlg('Canceled by user', 'Information'); -%! else -%! volume = str2num(dims{1}) * str2num(dims{2}) * str2num(dims{3}); -%! surface = 2 * (str2num(dims{1}) * str2num(dims{2}) + ... -%! str2num(dims{2}) * str2num(dims{3}) + ... -%! str2num(dims{1}) * str2num(dims{3})); -%! helpdlg(sprintf('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); -%! end +%! disp ('- test inputdlg with prompt and caption only.'); +%! prompt = {'Width','Height','Depth'}; +%! dims = inputdlg (prompt, 'Enter Box Dimensions'); +%! if (isempty (dims)) +%! helpdlg ('Canceled by user', 'Information'); +%! else +%! volume = str2num (dims{1}) * str2num (dims{2}) * str2num (dims{3}); +%! surface = 2 * (str2num (dims{1}) * str2num (dims{2}) + ... +%! str2num (dims{2}) * str2num (dims{3}) + ... +%! str2num (dims{1}) * str2num (dims{3})); +%! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); +%! end + +%!demo +%! disp ('- test inputdlg with prescribed scalar (2 lines per text field) and defaults.'); +%! prompt = {'Width','Height','Depth'}; +%! default = {'1.1','2.2','3.3'}; +%! rc = 2; +%! dims = inputdlg (prompt, 'Enter Box Dimensions',rc,default); +%! if (isempty (dims)) +%! helpdlg ('Canceled by user', 'Information'); +%! else +%! volume = str2num (dims{1}) * str2num (dims{2}) * str2num (dims{3}); +%! surface = 2 * (str2num (dims{1}) * str2num (dims{2}) + ... +%! str2num (dims{2}) * str2num (dims{3}) + ... +%! str2num (dims{1}) * str2num (dims{3})); +%! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); +%! end %!demo -%! disp('- test inputdlg with prescribed vector [1,2,3] for # of lines per text field and defaults.'); -%! prompt = {'Width','Height','Depth'}; -%! default = {'1.10', '2.10', '3.10'}; -%! rc = [1,2,3]; % NOTE: must be an array -%! dims = inputdlg ( prompt, 'Enter Box Dimensions',rc,default ); -%! if isempty(dims) -%! helpdlg('Canceled by user', 'Information'); -%! else -%! volume = str2num(dims{1}) * str2num(dims{2}) * str2num(dims{3}); -%! surface = 2 * (str2num(dims{1}) * str2num(dims{2}) + ... -%! str2num(dims{2}) * str2num(dims{3}) + ... -%! str2num(dims{1}) * str2num(dims{3})); -%! helpdlg(sprintf('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); -%! end +%! disp ('- test inputdlg with prescribed vector [1,2,3] for # of lines per text field and defaults.'); +%! prompt = {'Width','Height','Depth'}; +%! default = {'1.10', '2.10', '3.10'}; +%! rc = [1,2,3]; % NOTE: must be an array +%! dims = inputdlg (prompt, 'Enter Box Dimensions',rc,default); +%! if (isempty (dims)) +%! helpdlg ('Canceled by user', 'Information'); +%! else +%! volume = str2num (dims{1}) * str2num (dims{2}) * str2num (dims{3}); +%! surface = 2 * (str2num (dims{1}) * str2num (dims{2}) + ... +%! str2num (dims{2}) * str2num (dims{3}) + ... +%! str2num (dims{1}) * str2num (dims{3})); +%! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); +%! end %!demo -%! disp('- test inputdlg with prescribed row by column sizes and defaults.'); -%! prompt = {'Width','Height','Depth'}; -%! default = {'1.10', '2.20', '3.30'}; -%! rc = [1,10; 2,20; 3,30]; % NOTE: must be an array -%! dims = inputdlg ( prompt, 'Enter Box Dimensions',rc,default ); -%! if isempty(dims) -%! helpdlg('Canceled by user', 'Information'); -%! else -%! volume = str2num(dims{1}) * str2num(dims{2}) * str2num(dims{3}); -%! surface = 2 * (str2num(dims{1}) * str2num(dims{2}) + ... -%! str2num(dims{2}) * str2num(dims{3}) + ... -%! str2num(dims{1}) * str2num(dims{3})); -%! helpdlg(sprintf('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); -%! end +%! disp ('- test inputdlg with prescribed row by column sizes and defaults.'); +%! prompt = {'Width','Height','Depth'}; +%! default = {'1.10', '2.20', '3.30'}; +%! rc = [1,10; 2,20; 3,30]; % NOTE: must be an array +%! dims = inputdlg (prompt, 'Enter Box Dimensions',rc,default); +%! if (isempty (dims)) +%! helpdlg ('Canceled by user', 'Information'); +%! else +%! volume = str2num (dims{1}) * str2num (dims{2}) * str2num (dims{3}); +%! surface = 2 * (str2num (dims{1}) * str2num (dims{2}) + ... +%! str2num (dims{2}) * str2num (dims{3}) + ... +%! str2num (dims{1}) * str2num (dims{3})); +%! helpdlg (sprintf ('Results:\nVolume = %.3f\nSurface = %.3f', volume, surface), 'Box Dimensions'); +%! end + diff -r c55df4e5e216 -r e39f00a32dc7 scripts/ui/listdlg.m --- a/scripts/ui/listdlg.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/ui/listdlg.m Tue Jul 09 14:04:05 2013 -0700 @@ -94,21 +94,21 @@ ## handle key, value pairs for i = 1:2:nargin-1 - if strcmp (varargin{i}, "ListString") + if (strcmp (varargin{i}, "ListString")) listcell = varargin{i+1}; - elseif strcmp (varargin{i}, "SelectionMode") + elseif (strcmp (varargin{i}, "SelectionMode")) selmode = varargin{i+1}; - elseif strcmp (varargin{i}, "ListSize") + elseif (strcmp (varargin{i}, "ListSize")) listsize = varargin{i+1}; - elseif strcmp (varargin{i}, "InitialValue") + elseif (strcmp (varargin{i}, "InitialValue")) initialvalue = varargin{i+1}; - elseif strcmp (varargin{i}, "Name") + elseif (strcmp (varargin{i}, "Name")) name = varargin{i+1}; - elseif strcmp (varargin{i}, "PromptString") + elseif (strcmp (varargin{i}, "PromptString")) prompt = varargin{i+1}; - elseif strcmp (varargin{i}, "OKString") + elseif (strcmp (varargin{i}, "OKString")) okstring = varargin{i+1}; - elseif strcmp (varargin{i}, "CancelString") + elseif (strcmp (varargin{i}, "CancelString")) cancelstring = varargin{i+1}; endif endfor @@ -137,7 +137,7 @@ ## swap width and height to correct calling format for JDialogBox listsize = {num2str(listsize(2)), num2str(listsize(1))}; initialvalue = arrayfun (@num2str, initialvalue, "UniformOutput", false); - if isempty(prompt) + if (isempty (prompt)) prompt = {""}; endif @@ -158,35 +158,37 @@ endfunction + %!demo -%! disp('- test listdlg with selectionmode single. No caption, no prompt.'); -%! itemlist = {'An item \\alpha', 'another', 'yet another'}; -%! s = listdlg ( 'ListString',itemlist, 'SelectionMode','Single' ); -%! imax = numel (s); -%! for i=1:1:imax -%! disp(['Selected: ',num2str(i),': ', itemlist{s(i)}]); -%! end +%! disp ('- test listdlg with selectionmode single. No caption, no prompt.'); +%! itemlist = {'An item \\alpha', 'another', 'yet another'}; +%! s = listdlg ('ListString',itemlist, 'SelectionMode','Single'); +%! imax = numel (s); +%! for i=1:1:imax +%! disp (['Selected: ',num2str (i),': ', itemlist{s (i)}]); +%! end %!demo -%! disp('- test listdlg with selectionmode and preselection. Has caption and two lines prompt.'); -%! itemlist = {'An item \\alpha', 'another', 'yet another'}; -%! s = listdlg ( 'ListString',itemlist, ... -%! 'SelectionMode','Multiple', ... -%! 'Name','Selection Dialog', ... -%! 'InitialValue',[1,2,3,4], -%! 'PromptString',{'Select an item...', '...or multiple items'} ); -%! imax = numel (s); -%! for i=1:1:imax -%! disp(['Selected: ',num2str(i),': ', itemlist{s(i)}]); -%! end +%! disp ('- test listdlg with selectionmode and preselection. Has caption and two lines prompt.'); +%! itemlist = {'An item \\alpha', 'another', 'yet another'}; +%! s = listdlg ('ListString',itemlist, ... +%! 'SelectionMode','Multiple', ... +%! 'Name','Selection Dialog', ... +%! 'InitialValue',[1,2,3,4], +%! 'PromptString',{'Select an item...', '...or multiple items'} ); +%! imax = numel (s); +%! for i=1:1:imax +%! disp (['Selected: ',num2str (i),': ', itemlist{s (i)}]); +%! end %!demo -%! disp('- test listdlg with listsize.'); -%! itemlist = {"Neutron","Electron","Quark","Proton","Neutrino"}; -%! s = listdlg ( "ListString",itemlist, -%! "Name","Bits and Pieces", -%! "ListSize",[200 75] ); -%! imax = numel (s); -%! for i=1:1:imax -%! disp(['Selected: ',num2str(i),': ', itemlist{s(i)}]); -%! end +%! disp ('- test listdlg with listsize.'); +%! itemlist = {"Neutron","Electron","Quark","Proton","Neutrino"}; +%! s = listdlg ("ListString",itemlist, +%! "Name","Bits and Pieces", +%! "ListSize",[200 75] ); +%! imax = numel (s); +%! for i=1:1:imax +%! disp (['Selected: ',num2str (i),': ', itemlist{s (i)}]); +%! end + diff -r c55df4e5e216 -r e39f00a32dc7 scripts/ui/questdlg.m --- a/scripts/ui/questdlg.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/ui/questdlg.m Tue Jul 09 14:04:05 2013 -0700 @@ -120,55 +120,56 @@ endfunction + %!demo -%! disp('- test questdlg with two buttons'); -%! a = questdlg('Would you like some free money?',... +%! disp ('- test questdlg with two buttons'); +%! a = questdlg ('Would you like some free money?',... %! '$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $',... %! 'No', 'Cancel', 'Cancel'); -%! if strcmp (a, 'No') -%! msgbox('Suit yourself.', 'Message Box'); -%! endif +%! if (strcmp (a, 'No')) +%! msgbox ('Suit yourself.', 'Message Box'); +%! endif %!demo -%! disp('- test questdlg with message and title only.'); -%! a = 'No'; -%! c = 0; -%! while (strcmp(a, 'No') || !c) -%! a = questdlg('Close this Question Dialog?', 'Reductio Ad Absurdum'); -%! if strcmp(a, 'Yes') -%! q = 'Are you sure?'; -%! while (strcmp(a, 'Yes') && !c) -%! a = questdlg(q, 'Reductio Ad Absurdum'); -%! word = ' really'; -%! i = strfind(q, word); -%! if isempty( i ) -%! i = strfind(q, ' sure'); -%! q = [q '!']; -%! else -%! word = [word ',']; -%! endif -%! q = [q(1:i-1) word q(i:end)]; -%! endwhile -%! endif -%! if strcmp(a, 'Cancel') -%! warndlg('Answer "Yes" or "No".', 'Warning Dialog'); -%! a = 'No'; -%! c = 1; -%! endif -%! endwhile -%! msgbox('Whew!'); +%! disp ('- test questdlg with message and title only.'); +%! a = 'No'; +%! c = 0; +%! while (strcmp (a, 'No') || !c) +%! a = questdlg ('Close this Question Dialog?', 'Reductio Ad Absurdum'); +%! if (strcmp (a, 'Yes')) +%! q = 'Are you sure?'; +%! while (strcmp (a, 'Yes') && !c) +%! a = questdlg (q, 'Reductio Ad Absurdum'); +%! word = ' really'; +%! i = strfind (q, word); +%! if (isempty (i)) +%! i = strfind (q, ' sure'); +%! q = [q '!']; +%! else +%! word = [word ',']; +%! endif +%! q = [q(1:i-1) word q(i:end)]; +%! endwhile +%! endif +%! if (strcmp (a, 'Cancel')) +%! warndlg ('Answer "Yes" or "No".', 'Warning Dialog'); +%! a = 'No'; +%! c = 1; +%! endif +%! endwhile +%! msgbox ('Whew!'); %!demo -%! disp('- test questdlg with five inputs'); -%! ans = questdlg('Are you ready Steve?', 'Brian', 'No', 'Uh huh', 'Uh huh'); -%! if !strcmp (ans, 'No') -%! ans = questdlg ('Andy?', 'Brian', 'No', 'Yeah', 'Yeah'); -%! if !strcmp (ans, 'No') -%! ans = questdlg ('Mick?', 'Brian', 'No', 'Okay', 'Okay'); -%! if !strcmp (ans, 'No') -%! ans = msgbox ("Well all right, fellas. \n\n Let''s GO!!!!!",... -%! 'Ballroom Blitz', 'none'); -%! endif -%! endif -%! endif +%! disp ('- test questdlg with five inputs'); +%! ans = questdlg ('Are you ready Steve?', 'Brian', 'No', 'Uh huh', 'Uh huh'); +%! if (! strcmp (ans, 'No')) +%! ans = questdlg ('Andy?', 'Brian', 'No', 'Yeah', 'Yeah'); +%! if (! strcmp (ans, 'No')) +%! ans = questdlg ('Mick?', 'Brian', 'No', 'Okay', 'Okay'); +%! if (! strcmp (ans, 'No')) +%! ans = msgbox ("Well all right, fellas. \n\n Let''s GO!!!!!",... +%! 'Ballroom Blitz', 'none'); +%! endif +%! endif +%! endif diff -r c55df4e5e216 -r e39f00a32dc7 scripts/ui/warndlg.m --- a/scripts/ui/warndlg.m Tue Jul 09 12:22:33 2013 -0700 +++ b/scripts/ui/warndlg.m Tue Jul 09 14:04:05 2013 -0700 @@ -39,10 +39,12 @@ endfunction -%!demo -%! disp('- test warndlg with prompt only.'); -%! warndlg('Oh, a warning occured'); %!demo -%! disp('- test warndlg with prompt and caption.'); -%! warndlg('Oh, No...','This is the last Warning'); +%! disp ('- test warndlg with prompt only.'); +%! warndlg ('Oh, a warning occured'); + +%!demo +%! disp ('- test warndlg with prompt and caption.'); +%! warndlg ('Oh, No...','This is the last Warning'); +