source: Roms_tools/mexcdf/netcdf_toolbox/netcdf/@ncitem/uigetvar.m @ 1

Last change on this file since 1 was 1, checked in by cholod, 13 years ago

import Roms_Agrif

File size: 1.2 KB
Line 
1function theResult = uigetvar(self)
2
3% ncitem/uigetvar -- Get a NetCDF variable via dialog.
4%  uigetvar(self) returns one variable from the NetCDF file
5%   associated with self, an "ncitem" object, selected from
6%   a list-dialog.  The returned item is an "ncvar" object,
7%   or the empty-matrix [] if no variable is selected.
8 
9% Copyright (C) 1997 Dr. Charles R. Denham, ZYDECO.
10%  All Rights Reserved.
11%   Disclosure without explicit written consent from the
12%    copyright owner does not constitute publication.
13 
14% Version of 01-Dec-1997 13:20:58.
15
16if nargin < 1, help(mfilename), return, end
17
18result = [];
19
20theParent = parent(parent(self));
21theFilename = name(theParent);
22f = find(theFilename == filesep);
23if any(f)
24   theFilename(1:f(length(f))) = '';
25end
26
27theVars = var(self);
28theVarnames = ncnames(theVars);
29if ~isempty(theVarnames)
30   thePrompt = {'Select Variable From', 'NetCDF File', ['"' theFilename '"']};
31   theSelection = listdlg('ListString', theVarnames, ...
32                          'SelectionMode', 'single', ...
33                          'PromptString', thePrompt);
34   if any(theSelection)
35      result = theVars{theSelection};
36   end
37else
38   disp(' ## No variables available.')
39end
40
41if nargout > 0
42   theResult = result;
43else
44   ncans(result)
45end
Note: See TracBrowser for help on using the repository browser.