diff scripts/gui/uiputfile.m @ 19833:9fc020886ae9

maint: Clean up m-files to follow Octave coding conventions. Try to trim long lines to < 80 chars. Use '##' for single line comments. Use '(...)' around tests for if/elseif/switch/while. Abut cell indexing operator '{' next to variable. Abut array indexing operator '(' next to variable. Use space between negation operator '!' and following expression. Use two newlines between endfunction and start of %!test or %!demo code. Remove unnecessary parens grouping between short-circuit operators. Remove stray extra spaces (typos) between variables and assignment operators. Remove stray extra spaces from ends of lines.
author Rik <rik@octave.org>
date Mon, 23 Feb 2015 14:54:39 -0800
parents a9952a647d52
children 9b7ca334a104
line wrap: on
line diff
--- a/scripts/gui/uiputfile.m	Mon Feb 23 16:42:25 2015 +0000
+++ b/scripts/gui/uiputfile.m	Mon Feb 23 14:54:39 2015 -0800
@@ -21,8 +21,10 @@
 ## @deftypefnx {Function File} {[@var{fname}, @var{fpath}, @var{fltidx}] =} uiputfile (@var{flt})
 ## @deftypefnx {Function File} {[@var{fname}, @var{fpath}, @var{fltidx}] =} uiputfile (@var{flt}, @var{dialog_name})
 ## @deftypefnx {Function File} {[@var{fname}, @var{fpath}, @var{fltidx}] =} uiputfile (@var{flt}, @var{dialog_name}, @var{default_file})
-## Open a GUI dialog for selecting a file.  @var{flt} contains a (list of) file
-## filter string(s) in one of the following formats:
+## Open a GUI dialog for selecting a file.
+##
+## @var{flt} contains a (list of) file filter string(s) in one of the following
+## formats:
 ##
 ## @table @asis
 ## @item @qcode{"/path/to/filename.ext"}
@@ -56,23 +58,17 @@
 
 function [retfile, retpath, retindex] = uiputfile (varargin)
 
-  funcname = __get_funcname__ (mfilename ());
-
   if (nargin > 3)
     print_usage ();
   endif
 
-  defaultvals = {cell(0, 2),     # File Filter
-                 "Save File",    # Dialog Title
-                 "",             # Default file name
-                 [240, 120],     # Dialog Position (pixel x/y)
-                 "create",
-                 pwd};           # Default directory
-
-  outargs = cell (6, 1);
-  for i = 1 : 6
-    outargs{i} = defaultvals{i};
-  endfor
+  ## Preset default values
+  outargs = {cell(0, 2),     # File Filter
+             "Save File",    # Dialog Title
+             "",             # Default file name
+             [240, 120],     # Dialog Position (pixel x/y)
+             "create",
+             pwd};           # Default directory
 
   if (nargin > 0)
     file_filter = varargin{1};
@@ -114,17 +110,17 @@
   if (isguirunning ())
     [retfile, retpath, retindex] = __octave_link_file_dialog__ (outargs{:});
   else
+    funcname = __get_funcname__ (mfilename ());
     [retfile, retpath, retindex] = feval (funcname, outargs{:});
   endif
 
-  # add extension to the name it isnt already added
-
-  if ischar (retfile)
+  ## Append extension to the name if it isn't already added.
+  if (ischar (retfile))
     ext = outargs{1}{retindex};
-    ext = strrep (ext, '*', '');
+    ext = strrep (ext, "*", "");
 
-    if length (retfile) >= length (ext)
-      if ! strcmp (retfile(end-length (ext)+1:end), ext)
+    if (length (retfile) >= length (ext))
+      if (! strcmp (retfile(end-length (ext)+1:end), ext))
         retfile = [retfile ext];
       endif
     endif