Jump to content

Recommended Posts

Posted

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?

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
  • 5 years later...
Posted

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. 

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
  • Recently Browsing   0 members

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