comparison scripts/audio/@audioplayer/get.m @ 19557:5802ea7037d4

style fixes for audioplayer and audiorecorder classes * @audioplayer/__get_properties__.m, @audioplayer/audioplayer.m, @audioplayer/display.m, @audioplayer/get.m, @audioplayer/isplaying.m, @audioplayer/pause.m, @audioplayer/play.m, @audioplayer/playblocking.m, @audioplayer/resume.m, @audioplayer/set.m, @audioplayer/stop.m, @audioplayer/subsasgn.m, @audioplayer/subsref.m, @audiorecorder/__get_properties__.m, @audiorecorder/audiorecorder.m, @audiorecorder/display.m, @audiorecorder/get.m, @audiorecorder/getaudiodata.m, @audiorecorder/getplayer.m, @audiorecorder/isrecording.m, @audiorecorder/pause.m, @audiorecorder/play.m, @audiorecorder/record.m, @audiorecorder/recordblocking.m, @audiorecorder/resume.m, @audiorecorder/set.m, @audiorecorder/stop.m, @audiorecorder/subsasgn.m, @audiorecorder/subsref.m: Style fixes. Do more basic argument checking. Use consistent style for error messages.
author John W. Eaton <jwe@octave.org>
date Fri, 02 Jan 2015 17:23:38 -0500
parents dac3191a5301
children 72304a4e010a
comparison
equal deleted inserted replaced
19556:fc03d6e0d842 19557:5802ea7037d4
25 ## player object, return a scalar structure with values of all 25 ## player object, return a scalar structure with values of all
26 ## properties of @var{player}. The field names of the structure 26 ## properties of @var{player}. The field names of the structure
27 ## correspond to property names. 27 ## correspond to property names.
28 ## @end deftypefn 28 ## @end deftypefn
29 29
30 function result = get (varargin) 30 function retval = get (varargin)
31 player = varargin{1}; 31
32 properties = __get_properties__ (player); 32 if (nargin < 1 || nargin > 2)
33 print_usage ();
34 endif
35
36 properties = __get_properties__ (varargin{1});
37
33 if (nargin == 1) 38 if (nargin == 1)
34 result = properties; 39 retval = properties;
35 elseif (nargin == 2) 40 elseif (nargin == 2)
36 if (ischar (varargin{2})) 41 pnames = varargin{2};
37 result = getfield (properties, varargin{2}); 42 if (ischar (pnames))
43 retval = getfield (properties, pnames);
44 elseif (iscellstr (pnames))
45 retval = cell (size (pnames));
46 for i = 1:numel (pnames)
47 retval{i} = getfield (properties, pnames{i});
48 endfor
38 else 49 else
39 result = {}; 50 error ("@audioplayer/get: invalid name argument");
40 index = 1;
41 for property = varargin{2}
42 result{index} = getfield (properties, char (property));
43 index = index + 1;
44 endfor
45 endif 51 endif
46 else
47 error ("audioplayer: wrong number of arguments to the get method");
48 endif 52 endif
53
49 endfunction 54 endfunction