MATLAB Answers

How to "quicksave" a file in app designer?

조회 수: 3(최근 30일)
Huguette Djoumsap Takam
Huguette Djoumsap Takam 2021년 7월 30일
댓글: Huguette Djoumsap Takam 2021년 8월 15일
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

답변(1개)

Matt J
Matt J 2021년 7월 30일
편집: Matt J 2021년 7월 30일
The 3rd argument to uiputfile should end with a path separation character:
[file,path] = uiputfile(".mat","Save AnimTronics System",sysName + "_" + dStr + filesep);
  댓글 수: 4
Huguette Djoumsap Takam
Huguette Djoumsap Takam 2021년 8월 15일
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

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by