Giusy Active Member Licensed User Mar 11, 2019 #1 Hi, I have a button called "STOP" when I press it I want to get out of For and Next Code: Copy Fox x = 1 to 100 ..... ..... ???? <---- the button "Stop" has been pressed and then Exit ..... next It will be very simple for you, but I do not know how to intercept the button Thank you
Hi, I have a button called "STOP" when I press it I want to get out of For and Next Code: Copy Fox x = 1 to 100 ..... ..... ???? <---- the button "Stop" has been pressed and then Exit ..... next It will be very simple for you, but I do not know how to intercept the button Thank you
Erel B4X founder Staff member Licensed User Longtime User Mar 11, 2019 #2 What happens inside this loop? Can you post the code? Upvote 0
Eme Fibonacci Well-Known Member Licensed User Longtime User Mar 11, 2019 #3 Code: Copy Sub Globals Dim stop As Boolean End Sub For x=1 To 100 Log(x) If stop Then Exit Next Sub Button1_Click stop=True End Sub Upvote 0
Code: Copy Sub Globals Dim stop As Boolean End Sub For x=1 To 100 Log(x) If stop Then Exit Next Sub Button1_Click stop=True End Sub
Erel B4X founder Staff member Licensed User Longtime User Mar 11, 2019 #4 This code will not work as the click event will only run after the loop ends. It will also take less than a 1ms to complete (test in release mode). Upvote 0
This code will not work as the click event will only run after the loop ends. It will also take less than a 1ms to complete (test in release mode).
Star-Dust Expert Licensed User Longtime User Mar 11, 2019 #5 also Code: Copy For x = 1 to 100 ..... ..... Sleep(1) If ExitVariabile=true then X=101 ..... next Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Mar 11, 2019 #6 Unless you are calling Sleep or Wait For inside the loop then you cannot stop it with an external event. Upvote 0
Unless you are calling Sleep or Wait For inside the loop then you cannot stop it with an external event.
Eme Fibonacci Well-Known Member Licensed User Longtime User Mar 11, 2019 #7 Erel said: Unless you are calling Sleep or Wait For inside the loop then you cannot stop it with an external event. Click to expand... That's true. So I think something like this should be added: Code: Copy For x=1 To 100 Log(x) Sleep(100) If stop Then Exit Next Upvote 0
Erel said: Unless you are calling Sleep or Wait For inside the loop then you cannot stop it with an external event. Click to expand... That's true. So I think something like this should be added: Code: Copy For x=1 To 100 Log(x) Sleep(100) If stop Then Exit Next
Giusy Active Member Licensed User Mar 11, 2019 #8 Erel said: What happens inside this loop? Can you post the code? Click to expand... Hi @Erel I simplified the routine: Code: Copy Fox x = 1 to 10 tts.speak(testo(x) next Upvote 0
Erel said: What happens inside this loop? Can you post the code? Click to expand... Hi @Erel I simplified the routine: Code: Copy Fox x = 1 to 10 tts.speak(testo(x) next
Erel B4X founder Staff member Licensed User Longtime User Mar 11, 2019 #9 This code will complete in about 1ms. TTS.Speak is not a blocking call (with the exception of the deprecated modal dialogs, there are no blocking methods). The correct answer is: Code: Copy Sub Button1_Click tts.Stop End Sub Upvote 0
This code will complete in about 1ms. TTS.Speak is not a blocking call (with the exception of the deprecated modal dialogs, there are no blocking methods). The correct answer is: Code: Copy Sub Button1_Click tts.Stop End Sub
Giusy Active Member Licensed User Mar 11, 2019 #10 Erel said: This code will complete in about 1ms. TTS.Speak is not a blocking call (with the exception of the deprecated modal dialogs, there are no blocking methods). The correct answer is: Code: Copy Sub Button1_Click tts.Stop End Sub Click to expand... Thank you Upvote 0
Erel said: This code will complete in about 1ms. TTS.Speak is not a blocking call (with the exception of the deprecated modal dialogs, there are no blocking methods). The correct answer is: Code: Copy Sub Button1_Click tts.Stop End Sub Click to expand... Thank you