From: Lukáš Jiřiště Date: Tue, 17 Dec 2024 08:40:22 +0000 (+0100) Subject: End create_meter gracefully on canceling uigetfile X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=72475c063f780ac95740e9c6635af0cf30b38962;p=Bubble_column.git End create_meter gracefully on canceling uigetfile Also make the script function when a single picture is chosen. --- diff --git a/create_meter.m b/create_meter.m index a107654..0fc1d30 100644 --- a/create_meter.m +++ b/create_meter.m @@ -6,8 +6,17 @@ FileType = '*.png'; last_path = get_last_path(); [filenames, last_path] = uigetfile([last_path '/' FileType], ... 'Select all files for meter creation', 'MultiSelect', 'on'); +if (isequal(filenames, 0)) + path(oldpath); + return ; +end +filenames = cellstr(filenames); update_last_path(last_path); mask = load_mask(); +if (isequal(mask, 0)) + path(oldpath); + return ; +end files = struct('name', cell(1, numel(filenames)), 'folder', cell(1,... numel(filenames))); [files.name] = deal(filenames{:}); @@ -26,7 +35,7 @@ for i = 1:numel(marks_pixels) end end [meter_file_name, meter_path] = uiputfile([path '/*.mtr'], 'Save your meter as...'); -if (meter_file_name ~= 0) +if (~isequal(meter_file_name, 0)) save_meter([meter_path '/' meter_file_name], meter) end path(oldpath);