No internet connection
  1. Home
  2. How to

Soundflow "Stop All" function without alert

By Kitch Membery @Kitch2019-10-22 20:32:47.453Z

As a fail-safe against accidentally triggering a macro, I have added a confirmation popup box to a few of my scripts and was wondering if there is a way to stop the script running without the sound flow notification created by sf.soundflow.stopAll();

Thanks :-)

//Create variable for confirmation popup.
var confirmAnswer;

//Confirmation popup.
if (confirm("Do you want to continue?") == false) {
    alert("The macro has been canceled");
    sf.soundflow.stopAll();
}
Solved in post #2, click to view
  • 6 replies
  1. Hi @Kitch

    Yes you can bail out silently of the current script by throwing a zero - like this:

    throw 0;
    

    If you throw anything else, like a string - that will be the error message shown:

    throw "You did something wrong";
    
    ReplySolution
    1. And by the way, very good to give the user options like that!

      Small nit: I would write your code like this:

      if (!confirm("Do you want to continue?")) throw 0;
      

      And skip the alert. If the user cancels, they cancel, and they know they did. (IMO)

      1. If you still want to show the user some info while cancelling, I would display it as a notification and not as an alert.
        An alert requires input. If they already cancelled, they shouldn't have to give input twice.
        But if you want to let them know that the cancel indeed happened, give a notification like this:

        if (!confirm("Do you want to continue?")) {
            log('Cancelled', 'Title of notification');
            throw 0;
        }
        1. In reply tochrscheuer:
          Kitch Membery @Kitch2019-10-22 21:16:37.090Z

          Bahahahahhahaa. Hilarious and true.

          Thanks mate!

          1. Haha sure :) Great to follow your progress!

            1. Another thing that's nice about confirm and using the ! not operator is that it reads if not confirm(ed) then ... exit