Android Question How do you stop the first condition?

Mikota

New Member
As you can see in the picture, I put two button when the button sos is active, state is equal to 1 , and when I press the power button, the first condition is established, and when press the power button again , I want to make a second condition. The first condition is immediately discontinued. Is this clear?

HBzxtJb.png
https://pasteboard.co/HBzxtJb.png


B4X:
If FlashMode.ToUpperCase = "OFF" Then
            Do While(state = 1)
                btn.Background = bmp1
                For i1 = 0 To 2
                    flash.FlashOn
                    Sleep(2000)
                    flash.FlashOff
                    Sleep(500)
                Next
                For i2 = 0 To 2
                    flash.FlashOn
                    Sleep(500)
                    flash.FlashOff
                    Sleep(500)
                Next
                Sleep(1000)
            Loop
        Else
            flash.FlashOff
            btn.Background = bmp2
        End If
 
Last edited:

OliverA

Expert
Licensed User
Longtime User
Is this clear?
Maybe.
B4X:
If FlashMode.ToUpperCase = "OFF" Then
            Do While(state = 1)
                btn.Background = bmp1
                If pushed = 1 Then 'pushed variable incremented for each power button push. If pushed first time, do the below
                   For i1 = 0 To 2
                     flash.FlashOn
                     Sleep(2000)
                     If pushed <> 1 Then Exit ' you wanted immediate, so let's quit in the middle too if something changes
                     flash.FlashOff
                     Sleep(500)
                   Next
               Else ' pushed is > 1
                For i2 = 0 To 2
                    flash.FlashOn
                    Sleep(500)
                    If pushed <> 2 Then Exit
                    flash.FlashOff
                    Sleep(500)
                Next
              End If
                Sleep(1000)
            Loop
        Else
            flash.FlashOff
            btn.Background = bmp2
        End If
 
Upvote 0
Top