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
| function test
clc
h = figure('tag','fenetre');
uicontrol('style','pushbutton',...
'units','normalized',...
'position',[0.25 0.25 0.5,0.2],...
'tag','bouton_charge',...
'string','charger fichier',...
'parent',h,...
'callback',@Fichier_a_charger_Callback);
uicontrol('style','edit',...
'units','normalized',...
'position',[0 0.5 1,0.2],...
'tag','fichier_charge',...
'string','nom du fichier',...
'parent',h);
handles=guihandles(h);
% handles.variables_a_initialiser = ...;
guidata(h,handles);
function Fichier_a_charger_Callback(obj,evnt)
handles = guidata(gcbf); % on a l'habitude de faire ceci au lieu de le passer en paramètre
[filename pathfile] = uigetfile; % Chemin du fichier au cas où tu changes de répertoire
fid = fopen(fullfile(pathfile,filename),'r'); % ouvre en lecture
%d=fread(c);
msgbox(fread(fid, '*char')'); % msgbox prend un string en entree
set(handles.fichier_charge,'string',filename); % Affiche le nom du fichier (propriété string)
fclose(fid);
guidata(gcbf, handles); |