フィルターのクリア

How to open current working directory if a certain folder doesn't exists in the directory?

2 ビュー (過去 30 日間)
Sanjay Yadav
Sanjay Yadav 2017 年 1 月 17 日
コメント済み: Stephen23 2021 年 2 月 14 日
So here is my code on a pushbutton callback:
prompt = {'Enter Patient Name or ID:'};
title = 'Input';
num_lines = 1;
defaultans = {'Patient'};
answer = inputdlg(prompt,title,num_lines,defaultans);
handles.file = cellstr(answer{1});
%Creating a new folder by the name of Patient's name that user entered
folder = handles.file{1}
guidata(hObject, handles);
mkdir(folder);
By far its working fine, now in a different pushbutton callback I want to display an error if the folder of same name already exists
folder = handles.file{1}
if exist(folder,'dir')
winopen(folder);
else
winopen(pwd);
end
But it shows error : Reference to non-existent field 'file'. Please Help. Thanks in advance
  3 件のコメント
Rena Berman
Rena Berman 2017 年 1 月 20 日
(Answers Dev) Restored Question.

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2017 年 1 月 17 日
Evidently your first function didn't execute so that file is not a new field attached to handles. Or guidata() didn't work, but that seems doubtful. Examine handles in the second function before it bombs (set a breakpoint) and make sure that file is a field that is still attached to handles.
  1 件のコメント
Image Analyst
Image Analyst 2017 年 1 月 17 日
Yes that's right. If you push the second button without pushing the first button first, then file will not be attached to handles yet.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by