From: RobuLAB on
Hi,
I'm making a GUI that has a menu bar containing 'load', 'save' and 'save as'.
When the user clicks 'save' I want the program to check if there's a full filename already given(from a previous load). If so, it should just save there, if not it should open save as.
The problem I'm having is that whenever I load something and then change it (by using a subgui), the save function doesn't work anymore.
When I load and click save immediately after I don't get an error. But since I'm saving the same thing I just loaded I have no way of checking if it was actually saved.

My code:
%load
[filename, pathname] = uigetfile('*.mat', 'choissisez le fichier');
if pathname == 0
return
end
handles.adres = fullfile(pathname,filename);

%save
if isempty(handles.adres)
enregistrer() % redirect to save_as
else
load echange; %echange is a file I use to temporarely store data

save ( handles.adres, 'motD_RN', 'motD_RD',...
'motD_SN', 'motD_SD', 'motD_TN','motD_TD','motG_RN','motG_RD',...
'motG_SN','motG_SD','motG_TN','motG_TD')

the error I'm getting:
??? Reference to non-existent field 'adres'.

Error in ==> overview>Save_Callback at 210
save ( handles.adres, 'motD_RN', 'motD_RD',...

does anyone know what I'm doing wrong?

Idealy I want my program to check if the loaded file is of the required format.
The file should contain 12 vectors (1,11) with specific names. Anyone who has an idea on how to check that?

Thanks in advance!