Jump to content

How to restart Func with loop when there are multiple If conditions?


Recommended Posts

Hello I have written a pretty long (but basic) script with many hundreds of lines. I'm not so advanced with AutoIt. Basically I have a function which is a big loop and it starts with While 1 and ends up with WEnd. It has been working just fine but now I would need to add there a couple of If conditions which should make the function start from beginning. I have been trying to find and learn what is the solution but I just cant understand how to do it?

I wouldn't want to post the whole script here as it is pretty long and there is also things which I would not like to show in public.

For example:

Func Man1()

While 1
;Do commands

If ... Then 
;Go to beginning of the function

Else
;Do commands

EndIf

;Do commands

If ... Then 
;Do commands

Else
;Go to beginning of the function

EndIf

WEnd
EndFunc

 

Link to comment
Share on other sites

I dont see a point where you ever exit that function, so I dont see a reason to make it a function at all.

Your best friends in this situation are ContinueLoop, ExitLoop, and you can call a function from inside a function so some of your commands or if statements can be part of another function to help break down the logic. 

Link to comment
Share on other sites

11 hours ago, ViciousXUSMC said:

I dont see a point where you ever exit that function,

a command could be Return

;Do commands

Btw, another way to make the function “start from the beginning” (Not Recommended):.

Man1()

 

Code hard, but don’t hard code...

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