qwertylol Posted April 18, 2007 Posted April 18, 2007 While 1 WhileEnd What does this mean? it's going to run until 1 <> 1 ?
SleepyXtreme Posted April 18, 2007 Posted April 18, 2007 that means while 1 exists, it's an infinite loop. so essentially it's until 1<>1
SadBunny Posted April 18, 2007 Posted April 18, 2007 that means while 1 exists, it's an infinite loop. so essentially it's until 1<>1 I always use: $hellFreezesOver = False do ;stuff until $hellFreezesOver ... which does exactly the same but explains it better Roses are FF0000, violets are 0000FF... All my base are belong to you.
hmsSurprise Posted April 18, 2007 Posted April 18, 2007 (edited) The why of it is that sometimes we just want to run a short throwaway script for a few minutes perhaps as a debugging aid and then it can just be killed by clicking Tools>Stop. For instance this little script by JdeB prints to the console window at the bottom of the editor and shows the className of what's under the mouse. While 1 ConsoleWrite('ControlGetFocus("") = ' & ControlGetFocus("") & @crlf ) sleep(1000) WEnd And sometimes it is used for things like a GUI Message Loop. See the example at the bottom of the GUIGetMsg help page. jh Edited April 18, 2007 by hmsSurprise
Toady Posted April 18, 2007 Posted April 18, 2007 while 1 is the same thing as While True. This should explain it better. $bval = True While $bval $bval = False ;This makes the while loop end Wend www.itoady.com A* (A-star) Searching Algorithm - A.I. Artificial Intelligence bot path finding
PsaltyDS Posted April 18, 2007 Posted April 18, 2007 I always use: $hellFreezesOver = False do ;stuff until $hellFreezesOver ... which does exactly the same but explains it better Just to be thorough: While/WEnd and Do/Until perform their tests at different times. So this example is not equivalent to the original post's. A While loop does the test BEFORE running the code inside the loop. So if the test condition is false to begin with, the code in the loop never gets run. A Do loop does the test AFTER running the code in the loop. So the code is always run at least once, even if the test condition was always false. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
SadBunny Posted April 18, 2007 Posted April 18, 2007 (edited) Just to be thorough: While/WEnd and Do/Until perform their tests at different times. So this example is not equivalent to the original post's. A While loop does the test BEFORE running the code inside the loop. So if the test condition is false to begin with, the code in the loop never gets run. A Do loop does the test AFTER running the code in the loop. So the code is always run at least once, even if the test condition was always false. I know the difference, but thanks for explaining. Actually in this case what I meant by 'it does the same', was that they both will end up being an infinite loop if not exited in some way like ExitLoop or a change of $hellFreezesOver (in my example that is). But you are right ofcourse. You could rewrite it to a while loop and still retain my histerically funny contradictionary statement by doing: $hellFrozeOver = False While not $hellFrozeOver ; stuff WEnd Edited April 18, 2007 by SadBunny Roses are FF0000, violets are 0000FF... All my base are belong to you.
PsaltyDS Posted April 18, 2007 Posted April 18, 2007 It was for qwertylol's benefit. I did think yours was funny, and you inspired me to use this just a little while later in another thread: $Pigs_Fly = False Do ; Loop forever Until $Pigs_Fly Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
jvanegmond Posted April 18, 2007 Posted April 18, 2007 (edited) While 5 Edited April 18, 2007 by Manadar github.com/jvanegmond
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now