How does seperate script tell compiled GUI its done

2 views (last 30 days)
I have a simple Gui I built in App Designer that allows the user to select a file and fill in some text boxes. These box vaules are saved as variables in a mat file which is saved. The run button in the app calls a external script which loads these values into its workspace. The script then processes the file and can save out between 1 a 16 files. I have not been able to find a way to pass the status of the script back to the app as it saves each of the files. Closest I have came is using a msgbox which pops up a window between each file save. This does not work becasue it happens after the fact and either stays open and the next one stacks on top or I use pause and hold it open for x time then close which slows the process. And at the end I would like it to say done but am unsure how to do that either.
%% Point cloud export
% In this part of the code, the scatterplot is exported.
% Defining output document names
filename = sprintf([output_file_name,'_', num2str(iiii)]);
cd(output)
% Write file
pcloud{1,ii} = PC_Final1;
pcwrite(PC_Final1,filename,'PLYFormat','binary');
cd(input)
ref = []; % suppression of the loaded point cloud
f = msgbox((["Processed File:";output_file_name,'_', num2str(iiii) ' of 16\n']),"Status");
pause(10)
if isvalid(f); delete(f); end
How can I have the msgbox close when the next file is saved and after the last one say done?
  6 Comments
Walter Roberson
Walter Roberson on 29 May 2022
Unless you are using GPUs or parallel processing, or external processes, then the script does not return to the gui until the script finishes executing. As soon as you get back from the run() the script is finished.
Donny Mott
Donny Mott on 29 May 2022
No GPU or Parallel processing. Its just a simple script that I run from the gui and when the script is done the Gui has no idea its done. How can the Gui find out the script is done so that I can tell the user ithe script is done?
Must be a way to send command window text to the app. I tried diary and the script saved a file but it was empty and I am not sure how to tell the app when to read the file if I can get the script side working.

Sign in to comment.

Accepted Answer

Jan
Jan on 29 May 2022
The solution is trivial: Just add some code to show the progress. Your code was fine and efficient:
app.ProgressField.Value = "Processing PCAP File, Please Wait";
drawnow;
run('TLS_PCAP_script');
app.ProgressField.Value = "Processing Done";
drawnow;
What is your problem with this code? It shows "Please wait" until the script is running and "Done" afterwards.
By the way, using functions instead of scripts is strongly recommended for productive work. Keeping the workspace clean is important.
  7 Comments
Donny Mott
Donny Mott on 30 May 2022
Thank you for that. Good advice. Still learning. I have not tried to rewrite the original 300 line script to functions yet. But may once I learn more about programming.
Jan
Jan on 31 May 2022
Most likely all you need is to start the code by
function yourMFileName
and append an
end
Maybe some inputs and outputs must be defined.

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!