Changeset 379 for trunk/src/read_GUI.m
- Timestamp:
- Jan 27, 2012, 1:59:18 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/read_GUI.m
r363 r379 5 5 struct=[];%default 6 6 hchild=get(handle,'children'); 7 hchild=flipdim(hchild,1);% reverse the order to respect the tab order in the GUI 7 8 for ichild=1:numel(hchild) 8 9 if strcmp(get(hchild(ichild),'Visible'),'on') … … 15 16 object_style=get(hchild(ichild),'Style'); 16 17 check_input=1;%default 18 index=0; 17 19 switch object_style 18 20 case {'checkbox','radiobutton','togglebutton'} 19 21 input=get(hchild(ichild),'Value'); 20 22 case 'edit' 21 separator=regexp(tag,'^num_' );23 separator=regexp(tag,'^num_','once');%look for the prefix 'num_' 22 24 if isempty(separator) 23 25 input=get(hchild(ichild),'String'); 24 else 25 input=str2double(get(hchild(ichild),'String')); 26 else %transform into numeric if the edit box begins by the prefix 'num_' 27 input=str2double(get(hchild(ichild),'String')); 26 28 tag=regexprep(tag,'^num_',''); 29 % detect tag name ending by an index: then interpret the input as array(index) 30 r=regexp(tag,'_(?<index>\d+)$','names');% detect tag name ending by an index 31 if ~isempty(r) 32 tag=regexprep(tag,['_' r.index '$'],''); 33 index=str2double(r.index); 34 end 27 35 %deal with undefined input: retrieve the default value stored as UserData 28 36 if isnan(input) … … 39 47 check_input=0; 40 48 end 41 separator=regexp(tag,'^num_' );49 separator=regexp(tag,'^num_','once'); 42 50 if ~isempty(separator) 43 51 input=str2double(input);% transform to numerical values if the uicontrol tag begins with 'num_' … … 48 56 end 49 57 if check_input 50 struct.(tag)=input; 58 if index==0 59 struct.(tag)=input; 60 else 61 struct.(tag)(index)=input; 62 end 51 63 end 52 64 case 'uitable'
Note: See TracChangeset
for help on using the changeset viewer.