1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
%% pushbutton enregistrer
h19 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Position',[119.8 43.1538461538462 20.2 1.69230769230769],...
'String','Enregistrer',...
'callback',@save2txt,... %% appel prog sauvegarde fonction save2txt
'Tag','pushbutton1');
%% pushbutton retour retour au menu principal déja ouvert + apparition du bouton dès la sauvegarde
h20 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Position',[119.8 40.6923076923077 20.2 1.69230769230769],...
'String','Retour',...
'callback',@save_close,... %% appel save_close (prog qui stocke nom entraineur dans variable data)
'Tag','pushbutton2');
function varargout = save_close(vararin)
donnee.nom = get(handles.edit1, 'String'),... %% récup nom de l'entraineur
setappdata(0, 'Data', donnee),... %% sauvegarde le nom dans data
close(gcf); %% ferme la fenetre
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%%%%% SAUVEGARDER EN FORMAT TEXTE %%%%%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function save2txt(obj,event)
handles=guihandles(gcbf);
for k = 1:7
elem{k} = get(handles.(['edit',num2str(k+1)]),'string');
end
titres = {'nom','prénom','adress','ville','code postal','région','nationalité'}
[filename,pathname]=uiputfile('*.txt','sauvegarde')
if isequal(filename,0) || isequal(pathname,0)
disp('User pressed cancel')
else
fid = fopen(fullfile(pathname,filename),'wt');
fprintf(fid,'INFORMATIONS PRINCIPALES\n');
for k = 1:7
fprintf(fid,'%s : %s\n',titres{k},elem{k});
end
fclose(fid);
end |