Jump to content

How to Interupting the Loop for the True Condition


Recommended Posts

hi,

my list to do with my code are:

1. check if Input2 is "Input2" or "AAAA"

2. If Input2 is "Input2" then do endless looping for Func aaa() and Func bbb() (while 1)

3. If Input2 is "AAAA" then

    ConsoleWrite("Isi dari Input2 adalah : REPEATTTTTTTT"&@CRLF)

Looping it for 5 times if Inputbox2 still have "AAAA", but if i change the Inputbox2 to become "Input2" in the middle (beetwen 1 ~ 5 loops before) it will Exit the code.

how to make my code right?

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("Input1", 32, 32, 129, 21)
$Input2 = GUICtrlCreateInput("lose", 216, 32, 153, 21)
$Input3 = GUICtrlCreateInput("", 64, 112, 121, 21)
$Label1 = GUICtrlCreateLabel("baca", 32, 120, 28, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
aaa()
sleep(2000)
bbb()
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func aaa()

   $baca = guictrlread($Input1)
   ConsoleWrite("Isi dari Input1 adalah : "&$baca&@CRLF)
   ;sleep(1000)
EndFunc

Func bbb()

   $baca = guictrlread($Input2)

   if  $baca = "AAAA" Then
      For $i = 5 To 1 Step -1
      ConsoleWrite("Isi dari Input2 adalah : REPEATTTTTTTT"&@CRLF)
      sleep(1000)
      check()
      Next

   Elseif $baca = "Input2" Then
         ConsoleWrite("Isi dari Input2 adalah : EXITTTTT"&$baca&@CRLF)
   Else
   EndIf

   Exit
   sleep(1000)
EndFunc

FUnc check()
  aaa()
EndFunc

 

Edited by Tripoz
Link to comment
Share on other sites

In your bbb() function you have an Exit. You also have that followed by a Sleep.

That Exit will close your program, and Sleep will never be used.

I'm presuming you only want your program to Exit when you click exit?

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Its hard to make sense of what you want to achieve and your code (for me at least) but i think this is what you want based on your code:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("Input1", 32, 32, 129, 21)
$Input2 = GUICtrlCreateInput("lose", 216, 32, 153, 21)
$Input3 = GUICtrlCreateInput("", 64, 112, 121, 21)
$Label1 = GUICtrlCreateLabel("baca", 32, 120, 28, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
;aaa()
sleep(5000)
bbb()
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func aaa()

   $baca = guictrlread($Input1)
   ConsoleWrite("Isi dari Input1 adalah : "&$baca&@CRLF)
   ;sleep(1000)
EndFunc

Func bbb()

   $baca = guictrlread($Input2, 1)
   if  $baca = "AAAA" Then
      For $i = 5 To 1 Step -1
      ConsoleWrite("Isi dari Input2 adalah : REPEATTTTTTTT"&@CRLF)
              $recheck = guictrlread($Input2, 1)
              If $recheck = "Input2" Then
                  MsgBox(0, "", "Changed detected - " & $recheck)
                  Exit
              EndIf
      sleep(1000)
      check()
      Next

   Elseif $baca = "Input2" Then
         ConsoleWrite("Isi dari Input2 adalah : EXITTTTT"&$baca&@CRLF)
   Else
   EndIf

   Exit
   sleep(1000)
EndFunc

FUnc check()
  aaa()
EndFunc

 

Link to comment
Share on other sites

Its hard to make sense of what you want to achieve and your code (for me at least) but i think this is what you want based on your code:

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 437, 192, 124)
$Input1 = GUICtrlCreateInput("Input1", 32, 32, 129, 21)
$Input2 = GUICtrlCreateInput("lose", 216, 32, 153, 21)
$Input3 = GUICtrlCreateInput("", 64, 112, 121, 21)
$Label1 = GUICtrlCreateLabel("baca", 32, 120, 28, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
;aaa()
sleep(5000)
bbb()
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func aaa()

   $baca = guictrlread($Input1)
   ConsoleWrite("Isi dari Input1 adalah : "&$baca&@CRLF)
   ;sleep(1000)
EndFunc

Func bbb()

   $baca = guictrlread($Input2, 1)
   if  $baca = "AAAA" Then
      For $i = 5 To 1 Step -1
      ConsoleWrite("Isi dari Input2 adalah : REPEATTTTTTTT"&@CRLF)
              $recheck = guictrlread($Input2, 1)
              If $recheck = "Input2" Then
                  MsgBox(0, "", "Changed detected - " & $recheck)
                  Exit
              EndIf
      sleep(1000)
      check()
      Next

   Elseif $baca = "Input2" Then
         ConsoleWrite("Isi dari Input2 adalah : EXITTTTT"&$baca&@CRLF)
   Else
   EndIf

   Exit
   sleep(1000)
EndFunc

FUnc check()
  aaa()
EndFunc

 

yeah...thats exactly what i want...thx bro..

Edited by Tripoz
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...