No internet connection
  1. Home
  2. How to

Promp with option to continue or cancel macro

By Thomas Gloor @Thomas_Gloor
    2021-07-03 11:51:49.746Z

    Hi!

    I have a designed a script that does a lot of time based modification in the session.
    The trigger is a key on one of my stream decks. In the heat of a mix, there are chances I click it by mistake, which would wreak havoc in my current session.

    I'd like to add a prompt in the very beggining that works like that.

    Press macro button on stream deck

    Promp: are you sure you want to continue? Click OK to continue Abort to cancel.

    If clicking abort, the strip doesn't go thru.

    Any idea?

    Best,

    T

    • 15 replies
    1. samuel henriques @samuel_henriques
        2021-07-03 12:06:49.225Z

        Hello @Thomas_Gloor:

        I think this is what you are looking for

        1. TThomas Gloor @Thomas_Gloor
            2021-07-03 12:30:39.295Z

            Hey @samuel_henriques ,

            Thank you! I used

            //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();
            }
            

            But I do not understand where to put the

            throw 0;
            

            So I can avoid the SF notification at the top right of the window.

            Any idea?

            Best,
            T

            1. samuel henriques @samuel_henriques
                2021-07-03 12:35:45.654Z

                I think Christians's explanation works best:

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

                but if you still want to be informed it stoped:

                if (!confirm("Do you want to continue?")) {
                    log('Cancelled', 'Title of notification');
                    throw 0;
                }
                
                1. samuel henriques @samuel_henriques
                    2021-07-03 12:36:51.594Z

                    Kitch had the same question as you did. His code was almost there.

                    1. TThomas Gloor @Thomas_Gloor
                        2021-07-03 12:39:25.372Z

                        Thank you! I think I just to have a good grasp on what throw is...

                        Thanks again!

                        1. TThomas Gloor @Thomas_Gloor
                            2021-07-03 12:41:15.768Z

                            also, funny enough, when using

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

                            and cancelling, it still proceeds with the script!

                            1. samuel henriques @samuel_henriques
                                2021-07-03 12:45:06.251Z

                                try to restart soundFlow after changing the script. The stream deck or surfaces might still get the script when they booted.

                                1. TThomas Gloor @Thomas_Gloor
                                    2021-07-03 13:03:29.061Z

                                    Hey!

                                    I tried, but it still goes on! Maybe a wait?

                        2. T
                          In reply toThomas_Gloor:
                          Thomas Gloor @Thomas_Gloor
                            2021-07-03 13:06:02.653Z

                            it does so in 2 different scripts

                            1. samuel henriques @samuel_henriques
                                2021-07-03 13:11:46.558Z

                                Something else is going on.

                                You see the confirmation dialog?

                                try on a new blank script:

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

                                If you click ok, it should log "Hello"
                                If you click cancel nothing should happen

                                1. TThomas Gloor @Thomas_Gloor
                                    2021-07-03 13:19:45.722Z

                                    Your script does what it should,

                                    but when inserted in my script, it just doesn't stop when clicking cancel...
                                    weird...

                                    1. samuel henriques @samuel_henriques
                                        2021-07-03 13:41:00.705Z

                                        Submit a help/issue, the guys will be able to look into other details to figure it out.

                                        1. TThomas Gloor @Thomas_Gloor
                                            2021-07-03 14:02:38.304Z

                                            actually I tried.

                                            It seems to be the Throw 0 that doesn't work. Is there anything I should do to make it work? Define something beforehand?

                                            1. Dustin Harris @Dustin_Harris
                                                2021-07-04 03:14:01.632Z

                                                Are you using an uppercase T on throw 0? It should be lowercase…

                                                1. TThomas Gloor @Thomas_Gloor
                                                    2021-07-05 09:47:17.287Z

                                                    OH! Might be! I'll check when back at the studio!

                                                    Thank you!