MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Guide de l'utilisateur Page 460

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 759
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 459
10 Examples of GUIDE GUIs
Returns 1 for valid M AT-files and 0 if invalid (used by the Open menu
callback).
Saves the following items in the
handles structure:
- ThenameoftheMAT-file.
- The Address es structure.
- An index pointer indicating which name and phone number are currently
displayed
Check_And_Load Code Listing
This is the Che ck_A nd_Load function:
function pass = Check_And_Load(fil e,handles)
% Initialize the variable "pass" to determine if this is
% a valid file.
pass = 0;
% If called without any fil e then set file to the default
% filename.
% Otherwise, if the file ex ists then load it.
if isempty(f ile)
file = 'addrbook.mat';
handles.LastFile = file;
guidata(handles.Address_Book,handles)
end
if exist(fil e) == 2
data = load(file);
end
% Validate the MAT-file
% The file is valid if the variable is ca lled "Addresses"
% and it has fields called "Name" and "Pho ne"
flds = fieldnames(data);
if (length(f lds) == 1) && (strcmp(flds{1},'Address es'))
fields = fieldnames(data.Addresses );
if (length(fiel ds) == 2) && ...
(strcmp(fields{1},'Name')) && .. .
(strcmp(fields{2},'Phone'))
pass = 1;
end
10-86
Vue de la page 459
1 2 ... 455 456 457 458 459 460 461 462 463 464 465 ... 758 759

Commentaires sur ces manuels

Pas de commentaire