Sign in to follow this  
Followers 0
alientorress

While Not Loop problem!

7 posts in this topic

I just need to do a While Not Loop...

But i want the same While make more than 1 evaluation...

Example:

Func ActiveHit2()
$hitcounter2 = 0
$hitcounter2a = 0
$hitcounter2c = 0
  While Not ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:6]", "IsEnabled", "")
  Sleep(500)
  $hitcounter2 = $hitcounter2 + 1
  If $hitcounter2 >= 240 Then
  OnError()
  ExitLoop
  Else
  ContinueLoop
  EndIf
WEnd
While Not ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:5]", "IsEnabled", "")
  Sleep(500)
  $hitcounter2a = $hitcounter2a + 1
  If $hitcounter2a >= 240 Then
  OnError()
  ExitLoop
  Else
  ContinueLoop
  EndIf
WEnd
While Not ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:8]", "IsEnabled", "")
  Sleep(500)
  $hitcounter2c = $hitcounter2c + 1
  If $hitcounter2c >= 240 Then
  OnError()
  ExitLoop
  Else
  ContinueLoop
  EndIf
  WEnd
  Send("{ENTER}")
EndFunc

But this make Diferents While Loop, i want everything inside only one While because i think will be more eficient...

Thanks...

Share this post


Link to post
Share on other sites



Wrapping a loop with another and using arrays and variables is one way of doing it.

Func ActiveHit2()
  Local $hitcounter[3] = 0
  Local $sButton = ""
  Local $sWindowTitle = "Asistente para conexión nueva"

  For $i = 0 To 2
    switch $i
      case 0
        $sButton = "[CLASS:Button; INSTANCE:6]"
      case 1
        $sButton = "[CLASS:Button; INSTANCE:5]"
      case 2
        $sButton = "[CLASS:Button; INSTANCE:8]"
    EndSwitch

    While Not ControlCommand($sWindowTitle, "", $sButton, "IsEnabled", "")
      Sleep(500)
      $hitcounter[$i] += 1
      If $hitcounter[$i] >= 240 Then
        OnError()
        ExitLoop
      EndIf
    WEnd
  Next
  Send("{ENTER}")
EndFunc

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

Before i read ur reply i do it like this:

Func ActiveHit1()
If ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:2]", "IsEnabled", "") AND ControlCommand("Asistente para conexión nueva", "", "[CLASS:Button; INSTANCE:4]", "IsEnabled", "") Then
  Send("{ENTER}")
Else
  Sleep(500)
  $contadorhit = $contadorhit + 1
  If $contadorhit >= 240 Then
   OnError()
  Else
   ActiveHit1()
  EndIf
EndIf
EndFunc

And it work, the question now is in what way is more stable and fast? time and CPU load is critical for me because this script will run on a very old machine... PIII 700Mhz 256MB RAM.

And the other question... why i can't do:

IF THIS

AND

THIS

AND

THIS...

I always have to do:

IF THIS AND THIS AND THIS

all in a single line? problems with the editor or with the syntactical analysis of the compiler?

Share this post


Link to post
Share on other sites

Ohhh THANKS U so much by the way...

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I always have to do:

IF THIS AND THIS AND THIS

all in a single line?

Not if you don't want to. You can place 'space + underscore' at the end of each condition, and then carry on on the next line.

If _
    (2/2 = 1) And _
    (1^2 = 1) Then
    MsgBox(0, "Test", "All conditions are TRUE")
EndIf
Edited by czardas

Share this post


Link to post
Share on other sites

It is to do with how the language is structured. If you want to do it like that, then you have to add _ to your lines, like this:

IF THIS _

AND _

THIS _

AND _

THIS _

Then

You only add it to the lines where the command continues on the other line, but you cannot do this while using a literal (string for example). To do this you would do:

"Hello " & _

"World"

Which would be the same as "Hello " & "World".

Share this post


Link to post
Share on other sites

Thank u so much to everyone... THANKss... now please could some one tellme if my code will be more fast and with low CPU comsuption with the IF conditionals like i do it or better with the case example and arrays that czardas wrote?

Thank... nice comunity by the way i will keep in touch and share some code i wrote when is more stable and finished....

Thanks....

Share this post


Link to post
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
Sign in to follow this  
Followers 0