Andrejj

Calling a function in a while loop

4 posts in this topic

Hello,

currently I have a little problem which I cant solve.

I will just post an example which will make it easier to understand what I want to do.

While 1
Send("1")
Call("_stop")
Send("2")
exit
WEnd

Func _stop()
Send("ala")
EndFunc

When I run this Script it writes:

1ala2

But I want to do the following:

1ala1ala1

So afterall I want to call the function _stop and break the current while loop and restart at the first line again or better said at Send("1").

What I have to do?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Why the need for Call()? Also why have an Exit inside the loop? Just use ExitLoop or ContinueLoop. Have the Exit after the loop body.

While 1
  Send("1")
  switch Call("_stop")
    case 1
      ContinueLoop
    case -1
      ExitLoop
   EndSwitch
  Send("2")
WEnd

Exit


Func _stop()
  Send("ala")
  If $SkipReason then Return 1
  If $QuitReason then Return -1
  Return 0
EndFunc
Edited by MilesAhead

Share this post


Link to post
Share on other sites

Its coming up with 1ala2 because your second send says to send a "2". Also the loop isnt repeating because the exit is exiting the loop before it can repeat. Also if you want it to come out 1ala1ala1 then your loop shouldnt even contain the send ("2") because even if you change it to send ("1") as i stated above ot will say 1ala11ala1... and so on. 

Share this post


Link to post
Share on other sites

@ACExSPADE,

Welcome to our forums! 
What made you decide to answer in a thread which is 5 years old as a first post? :)

Jos

 

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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