Last change
on this file since 525 was
507,
checked in by sommeria, 12 years ago
|
various improvments and corrections
dtatatree_browser tested
|
File size:
749 bytes
|
Rev | Line | |
---|
[8] | 1 | %'update_menu': find an input string in a menu, add it to the menu at the penultimate position if it does not exist
|
---|
| 2 | %-----------------------------------------------
|
---|
| 3 | % function menu_str=update_menu(handle,strinput)
|
---|
| 4 | %
|
---|
| 5 | % OUTPUT:
|
---|
| 6 | % menu_str: new menu; cell of strings
|
---|
| 7 | %
|
---|
| 8 | % INPUT:
|
---|
| 9 | % handle: handle of the menu to modify (listbox uicontrol)
|
---|
| 10 | % strinput: char string to detect or add in the menu
|
---|
| 11 |
|
---|
| 12 | function menu_str=update_menu(handle,strinput)
|
---|
| 13 | menu_str=get(handle,'String');
|
---|
[236] | 14 | ichoice=find(strcmp(strinput,menu_str),1);
|
---|
| 15 | if isempty(ichoice)%the input string does not exist in the menu
|
---|
[507] | 16 | ichoice= length(menu_str);
|
---|
| 17 | menu_str=[menu_str(1:end-1);{strinput};menu_str(end)];
|
---|
[8] | 18 | set(handle,'String',menu_str)
|
---|
| 19 | end
|
---|
| 20 | set(handle,'Value',ichoice)
|
---|
Note: See
TracBrowser
for help on using the repository browser.