MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Podręcznik Użytkownika Strona 461

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 759
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 460
An Address Book Reader (GUIDE)
end
% If the file is valid, display it
if pass
% Add Addresses to the handles structure
handles.Addresses = data.Addresses;
guidata(handles.Address_Book,handles)
% Display the first entry
set(handles.Contact_Name,'String',data .Addresses(1).Name)
set(handles.Contact_Phone,'String',dat a.Addresses(1).Phone)
% Set the index pointer to 1 and save handle s
handles.Index = 1;
guidata(handles.Address_Book,handles)
else
errordlg('Not a valid Address Book','Address Book Error')
end
The Open Menu Callback
The address book GUI contains a File menu that has an Open submenu for
loading address book MAT-files. When selected, Open displays a dialog box
(
uigetfile)thatenablestheusertobrowseforfiles.Thedialogboxdisplays
only MAT-file s, but users ca n c h an ge th e filte r to disp la y all files.
The dialogbox returns both the file name and the path to the file, which is
then passed to
fullfile to ensure the p ath is properly constructed for any
platform.
Check_And_Load validates and load the new address b ook.
Open_Callback Code Listing
function Open_C allb ack(hObject, eventd ata, handles)
[filename, p athn ame] = uigetfile( . ..
{'*.mat', 'All MAT-Files (*.mat)'; ...
'*.*','All Fi les (*.*)'}, ...
'Select Address Book');
% If "Cancel" is selected then return
if isequal([ file name,pathname],[0,0])
return
% Otherwise construct the fullfilename and Che ck and load
% the file
else
10-87
Przeglądanie stron 460
1 2 ... 456 457 458 459 460 461 462 463 464 465 466 ... 758 759

Komentarze do niniejszej Instrukcji

Brak uwag