Jump to content

Recommended Posts

Posted

Is there a way to make while loops check the expression after each statement is executed? If not what are some ways to emulate this? Should I just put all the statements into an array then use for in next loop to kind of do the same thing? 

  • Moderators
Posted

@Rynhasautism how about an example of what you're meaning? It sounds like your While expression will change once you have entered the loop, and there are a couple of ways to skin the proverbial cat. But rather than guessing at what you're trying to do, and then crafting an example that would make sense to you, a detailed explanation of what you want the loop to do step by step would be helpful.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted (edited)
  On 8/4/2020 at 8:28 PM, Rynhasautism said:

Is there a way to make while loops check the expression after each statement is executed?

Expand  

like this ?

While 1
    ConsoleWrite("! do the stuff" & @CRLF)
    If Not 1=2 Then ExitLoop
WEnd

If this is what you was looking for (thinking about)..... you should focus on:
 

Do
    ConsoleWrite("! do the stuff" & @CRLF)
Until 1<>2

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

well a normal while is like 

While Expression() = $valueIWant
    Statement1()
    Statement2()
    Statement3()
WEnd

Where it only checks the expression at the start of the loop. I'm looking to do something like 

Expression() = $valueIWant
Statement1()
Expression() = $valueIWant
Statement2()
Expression() = $valueIWant
Statement3()

Was thinking of something like this at first but it doesn't exit the loop 

While $flag = $flagIWant
Statement1()    
WEnd
Func Statement1()
    Return $flag = Expression()
EndFunc

The for loop thing I was talking about was something like 

$aArray [1][2] = ["function", $parameter]


For $i = 1 To UBound($aArray) - 1
    
    If Expression() = $valueIWant Then 
        Local $FuncName = FuncName($aArray[$i][0])
        call($FuncName, $aArray[$i][1])
    EndIf
Next

 

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