How to "quicksave" a file in app designer?

1 visualización (últimos 30 días)
Huguette Djoumsap Takam
Huguette Djoumsap Takam el 30 de Jul. de 2021
Comentada: Huguette Djoumsap Takam el 15 de Ag. de 2021
Hi Community,
i devellop a little app for kinematic simulation and can save the simulation result. But i have an issue with my "quicksave" button.
The role of the "quicksave" button is to first save the simulation result as an normal save function. Then if i change something in the simuation then i need to save the changes without giving one more time a new pfad. It means, that "Quicksave"-function needs to remenber the save-path and if it exists save in that path.
Now i wrote this code, but everytime i clicked on the "quicksave"-button i still need to choose the path. Can anyon have an idea, where something i'm doing wrong?
Thanks in advance for the help
% Button pushed function: SaveButton
function SaveButtonPushed(app, event)
if app.isNotValid
return
end
dStr = string(datestr(now(),'yyyy-mm-dd_HH-MM'));
sysVar = app.System;
sysName = app.System.Name;
[file,path] = uiputfile(".mat","Save AnimTronics System",sysName + "_" + dStr);
% if isnumeric(file) && file == 0
% return
%end
fileName = fullfile(path,file);
% File exists
if exist(fileName,'file')
save(fileName,"sysVar");
else
%if file does not exist
Call_SaveAsButtonPushed(app)
end
end
end

Respuestas (1)

Matt J
Matt J el 30 de Jul. de 2021
Editada: Matt J el 30 de Jul. de 2021
The 3rd argument to uiputfile should end with a path separation character:
[file,path] = uiputfile(".mat","Save AnimTronics System",sysName + "_" + dStr + filesep);
  4 comentarios
Huguette Djoumsap Takam
Huguette Djoumsap Takam el 12 de Ag. de 2021
HI Matt,
Thanks for your answer, but it's not working.
Huguette Djoumsap Takam
Huguette Djoumsap Takam el 15 de Ag. de 2021
I have another question:
how can i, for the first step, save the filepath in a private property and then check if there is anything in the property?
If there is something, then the current path will be use for saving one more time. But if there is nothing in the property, the save function will be call.
Just need some ideas.
Thanks for helping

Iniciar sesión para comentar.

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by