How does seperate script tell compiled GUI its done

1 Ansicht (letzte 30 Tage)
Donny Mott
Donny Mott am 28 Mai 2022
Kommentiert: Jan am 31 Mai 2022
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 Kommentare
Walter Roberson
Walter Roberson am 29 Mai 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 am 29 Mai 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 29 Mai 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 Kommentare
Donny Mott
Donny Mott am 30 Mai 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 am 31 Mai 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by