MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Manuel d'utilisateur Page 267

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 330
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 266
An Address Book Reader
10-43
the Contact_Name_Callback or the Contact_Phone_Callback updates
handles.Addresses.
Saving the MAT-File
If the user selects Save, the save command is called to save the current
MAT-file with the new names and phone numbers.
If the user selects
Save As, a dialog is displayed (uiputfile) that enables the
user to select the name of an existing MAT-file or specify a new file. The dialog
returns the selected filename and path. The final steps include
Using
fullfile to create a platform-independent pathname.
Calling
save to save the new data in the MAT-file.
Updating the
handles structure to contain the new MAT-file name.
Calling
guidata to save the handles structure.
Save_Callback Code Listing
function Save_Callback(hObject, eventdata, handles)
% Get the Tag of the menu selected
Tag = get(hObject, 'Tag');
% Get the address array
Addresses = handles.Addresses;
% Based on the item selected, take the appropriate action
switch Tag
case 'Save'
% Save to the default addrbook file
File = handles.LastFile;
save(File,'Addresses')
case 'Save_As'
% Allow the user to select the file name to save to
[filename, pathname] = uiputfile( ...
{'*.mat';'*.*'}, ...
'Save as');
% If 'Cancel' was selected then return
if isequal([filename,pathname],[0,0])
return
else
% Construct the full path and save
File = fullfile(pathname,filename);
Vue de la page 266
1 2 ... 262 263 264 265 266 267 268 269 270 271 272 ... 329 330

Commentaires sur ces manuels

Pas de commentaire