MATLAB Answers

How to automatically scroll editor to specific place in code after asking for user input?

1 view (last 30 days)
Travis Briles
Travis Briles on 1 Jun 2021
Edited: Travis Briles on 1 Jun 2021
I have incorporated a "breakpoint-like" feature in my code that opens a dialogue box to ask the user if the background removal/peak finding is satisfactory. If I am unsatisfied and select "cancel" it functions like a breakpoint whereas if I am satisfied and select "continue" it evaluates the next section of code.
For completeness, here is the relevant section of code (FYI, my approach is based on this: https://www.mathworks.com/matlabcentral/answers/22626-ask-user-to-continue).
%% Adjust Peak Finding??? Continue Yes/No?
%https://www.mathworks.com/matlabcentral/answers/22626-ask-user-to-continue
promptMessage = sprintf('Satisfied with Background/Etalon Removal?,\nor Cancel to abort processing?');
button = questdlg(promptMessage, 'Continue', 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
return; % Or break or continue
end
This works well, but has the annoying feature that I have to manually scroll to the section where the relevant parameters are defined in order to change them (after changing them I re-run that section of code). Is there a way to programatically scroll the editor to a specific section of code if I select "cancel" (ie: unsatisfied)? The most useful approach would be to have a unique tag in the code for the desired line number as opposed to just scrolling to a specific line number because line numbers will change as I add/remove sections in the future.
Thanks in advance!
-Travis

Answers (0)

Community Treasure Hunt

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

Start Hunting!