Mercurial > octave-antonio
comparison scripts/gui/uigetdir.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 |
comparison
equal
deleted
inserted
replaced
19832:a1acca0c2216 | 19833:9fc020886ae9 |
---|---|
18 | 18 |
19 ## -*- texinfo -*- | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {@var{dirname} =} uigetdir () | 20 ## @deftypefn {Function File} {@var{dirname} =} uigetdir () |
21 ## @deftypefnx {Function File} {@var{dirname} =} uigetdir (@var{init_path}) | 21 ## @deftypefnx {Function File} {@var{dirname} =} uigetdir (@var{init_path}) |
22 ## @deftypefnx {Function File} {@var{dirname} =} uigetdir (@var{init_path}, @var{dialog_name}) | 22 ## @deftypefnx {Function File} {@var{dirname} =} uigetdir (@var{init_path}, @var{dialog_name}) |
23 ## Open a GUI dialog for selecting a directory. If @var{init_path} is not | 23 ## Open a GUI dialog for selecting a directory. |
24 ## given the current working directory is used. @var{dialog_name} may be | 24 ## |
25 ## used to customize the dialog title. | 25 ## If @var{init_path} is not given the current working directory is used. |
26 ## @var{dialog_name} may be used to customize the dialog title. | |
26 ## @seealso{uigetfile, uiputfile} | 27 ## @seealso{uigetfile, uiputfile} |
27 ## @end deftypefn | 28 ## @end deftypefn |
28 | 29 |
29 ## Author: Kai Habel | 30 ## Author: Kai Habel |
30 | 31 |
31 function dirname = uigetdir (init_path = pwd, dialog_name = "Select Directory to Open") | 32 function dirname = uigetdir (init_path = pwd, dialog_name = "Select Directory to Open") |
32 | 33 |
33 funcname = __get_funcname__ (mfilename ()); | |
34 | |
35 if (nargin > 2) | 34 if (nargin > 2) |
36 print_usage (); | 35 print_usage (); |
37 endif | 36 endif |
38 | 37 |
39 if (!ischar (init_path) || !ischar (dialog_name)) | 38 if (! ischar (init_path) || ! ischar (dialog_name)) |
40 error ("uigetdir: INIT_PATH and DIALOG_NAME must be string arguments"); | 39 error ("uigetdir: INIT_PATH and DIALOG_NAME must be string arguments"); |
41 endif | 40 endif |
42 | 41 |
43 if (!isdir (init_path)) | 42 if (! isdir (init_path)) |
44 init_path = fileparts (init_path); | 43 init_path = fileparts (init_path); |
45 endif | 44 endif |
46 | 45 |
47 if (isguirunning ()) | 46 if (isguirunning ()) |
48 file_filter = cell (0, 2); | 47 file_filter = cell (0, 2); |
53 [filename, dirname, filterindex] ... | 52 [filename, dirname, filterindex] ... |
54 = __octave_link_file_dialog__ (file_filter, dialog_name, | 53 = __octave_link_file_dialog__ (file_filter, dialog_name, |
55 default_file_name, dialog_position, | 54 default_file_name, dialog_position, |
56 dialog_mode, init_path); | 55 dialog_mode, init_path); |
57 else | 56 else |
57 funcname = __get_funcname__ (mfilename ()); | |
58 dirname = feval (funcname, init_path, dialog_name); | 58 dirname = feval (funcname, init_path, dialog_name); |
59 endif | 59 endif |
60 | |
60 endfunction | 61 endfunction |
61 | 62 |
62 | 63 |
63 %!demo | 64 %!demo |
64 %! uigetdir (pwd, 'Select Directory'); | 65 %! uigetdir (pwd, 'Select Directory'); |