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();
}
Linked from:
- Christian Scheuer @chrscheuer2019-10-22 21:13:02.670Z
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";
Christian Scheuer @chrscheuer2019-10-22 21:14:15.976Z
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)
Christian Scheuer @chrscheuer2019-10-22 21:16:09.364Z
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; }
- In reply tochrscheuer⬆:
Kitch Membery @Kitch2019-10-22 21:16:37.090Z
Bahahahahhahaa. Hilarious and true.
Thanks mate!
Christian Scheuer @chrscheuer2019-10-22 21:18:07.162Z
Haha sure :) Great to follow your progress!
Christian Scheuer @chrscheuer2019-10-22 21:19:41.448Z
Another thing that's nice about confirm and using the
!
not operator is that it readsif not confirm(ed) then ... exit