Jump to content

For Loop Infinite


Recommended Posts

Good day,

is it possible to make a For Loop infinite,

ho do i make a for loop infinite??? using the script below

For $i = 0 To 10
Msgbox(64, "Succes", $i)
Next

 

Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

  • Moderators

232showtime,

Use a While...WEnd loop - but you will need to have some way of exiting it at some point.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hello. As Melba says Correct way is using While. But a for can be infinite this way.

 

For $i = 0 To 1
Msgbox(64, "Succes", $i)
$i-=1
Next

Saludos

Link to comment
Share on other sites

BTW you can also run an unbounded loop with Do..Until

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Yes and since a so-called "infinite loop" has no exit condition, all forms are equivalent: a linear code block terminated by a backward branch. Note that the term infinite has zero practical meaning in computer science, since noone can reasonably expect anything being infinite in the real world. Abstract mathematical objects actually infinite aren't defined by means of an infinite loop.

It remains that Do..Until seems to be underused in code regularly posted, compared to While..Wend, without good reason in many situations. There is no theoretic grounds to infer that more than half of useful algorithms need to check exit condition at inner code block entry (While) or exit (Until).

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

1 hour ago, jchd said:

It remains that Do..Until seems to be underused in code regularly posted

I agree with you.

I was inferring that all loops in programming do pretty much the same thing: in so much as they repeat until a condition is met, or not. The comment was a follow up on your earlier post and I thought it worth a mention. Implementation may vary of course. I imagine loops which increment an iteration count ought theoretically be slower. It stands to reason, although in the real world things might not be so straight forward.

Link to comment
Share on other sites

My remark was more towards whether preconditions or postconditions dominate in loop constructs. Given a significant sample of distinct general-purpose algorithms, the ratio is close to 1/2, while in common code people tend to code While <cond> ... Wend with <cond> always true at entry.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

I meant to answer, but fell asleep. I was thinking it might be a good idea to get rid of the condition altogether and just simply have the loop. Terms like 'While', 'For' and 'Until' are rather specific. I'm speaking more generally in terms of language design - not necessarily AutoIt.

Edited by czardas
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

×
×
  • Create New...