Jump to content

Calling a function in a while loop


Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 5 years later...

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. 

Link to comment
Share on other sites

  • Developers

@ACExSPADE,

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

Jos

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...