How to "quicksave" a file in app designer?

1 view (last 30 days)
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

Answers (1)

Matt J
Matt J on 30 Jul 2021
Edited: Matt J on 30 Jul 2021
The 3rd argument to uiputfile should end with a path separation character:
[file,path] = uiputfile(".mat","Save AnimTronics System",sysName + "_" + dStr + filesep);
  4 Comments
Huguette Djoumsap Takam
Huguette Djoumsap Takam on 12 Aug 2021
HI Matt,
Thanks for your answer, but it's not working.
Huguette Djoumsap Takam
Huguette Djoumsap Takam on 15 Aug 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

Sign in to comment.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!