GEOSoft Posted May 4, 2009 Share Posted May 4, 2009 Not important but could be nice and it's really just for the devs As it is right now we have to use a variable whaen using the loop. For $x = 1 To 3 ; Do whatever. Next How difficult would it be to change that so we could also use For 1 To 3 ; Do whatever. Next What brought it to mind was this Local $aArray[50] For $i = 0 To Ubound($aArray) -1 $aArray[$i] = "" For $j = 1 To 3;; $j is never referenced so "For 1 To 3" would have been fine if it worked $aArray[$i] &= Chr(Random(97, 122, 1)) Next Next Valik has seen enouugh of the word "curious" so I won't use it. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Kip Posted May 4, 2009 Share Posted May 4, 2009 There're only a view cases in which you don't have to know $i, so why change the syntax for something that's very rare? MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Valik Posted May 4, 2009 Share Posted May 4, 2009 Eh, it's not very common to use a loop without needing the variable. I don't see why we need to introduce syntax that's likely to trip up new users just to provide minor syntactic sugar to support a corner case. Link to comment Share on other sites More sharing options...
GEOSoft Posted May 4, 2009 Author Share Posted May 4, 2009 Eh, it's not very common to use a loop without needing the variable. I don't see why we need to introduce syntax that's likely to trip up new users just to provide minor syntactic sugar to support a corner case.I hadn't considered the confusion angle, so question asked and answered. Chalk it up to another brilliant idea gone astray. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
WideBoyDixon Posted May 7, 2009 Share Posted May 7, 2009 Maybe there's scope in some distant future version for: Repeat 3 ; Do some stuff EndRepeat WBD [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
Valik Posted May 7, 2009 Share Posted May 7, 2009 Maybe there's scope in some distant future version for: Repeat 3 ; Do some stuff EndRepeat WBDNot when I can do it 3 different ways already: Local $i = 1 While $i <= 3 $i += 1 WEndoÝ÷ Ù«¢+Ù½ÈÀÌØí¤ôÄQ¼Ì)9áÐoÝ÷ Ù«¢+Ù1½°ÀÌØí¤ôÄ)¼(ÀÌØí¤¬ôÄ)U¹Ñ¥°ÀÌØí¤ÐìôÌ Link to comment Share on other sites More sharing options...
Richard Robertson Posted May 7, 2009 Share Posted May 7, 2009 (edited) Just think, if we had a goto, you could do it a fourth way. Local $i = 1 top: $i += 1 If $i < 3 Then Goto top Not to be taken seriously. Edited May 8, 2009 by Richard Robertson Link to comment Share on other sites More sharing options...
Administrators Jon Posted May 8, 2009 Administrators Share Posted May 8, 2009 There's some topic somewhere where I added this: Loop 10 EndLoop But there were no perf gains (the only possible benefit as we have so many different loops already) so I got rid of it. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
condoman Posted May 8, 2009 Share Posted May 8, 2009 I would agree to the GOTO only if it could be a computed one. Link to comment Share on other sites More sharing options...
WideBoyDixon Posted May 8, 2009 Share Posted May 8, 2009 (edited) Not when I can do it 3 different ways already:Is this a bad time to point out that the third one only loops twice? The original post was about not having to use a variable. I know it's not really important but none of these address the original proposal since they all use a variable. As an aside, the documentation says that the variable in a for loop will be created with local scope even if MustDeclareVars is turned on. Does anyone know if the scope is local to the for loop or local to the function?EDIT: Strike that, I just downloaded the source code from V3.1.0.0 and I see that it's created local to the function.WBD Edited May 8, 2009 by WideBoyDixon [center]Wide by name, Wide by nature and Wide by girth[u]Scripts[/u]{Hot Folders} {Screen Calipers} {Screen Crosshairs} {Cross-Process Subclassing} {GDI+ Clock} {ASCII Art Signatures}{Another GDI+ Clock} {Desktop Goldfish} {Game of Life} {3D Pie Chart} {Stock Tracker}[u]UDFs[/u]{_FileReplaceText} {_ArrayCompare} {_ToBase}~ My Scripts On Google Code ~[/center] Link to comment Share on other sites More sharing options...
GEOSoft Posted May 8, 2009 Author Share Posted May 8, 2009 (edited) Lets not regress to the GOTO (or GOSUB) discussion again. There are a few people around who probably still have someones boot print embedded on their arse over that. Edited May 8, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Kip Posted May 8, 2009 Share Posted May 8, 2009 Loops don't create a new scope. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
weaponx Posted May 8, 2009 Share Posted May 8, 2009 Loops don't create a new scope. Nope but the variable created in a For loop will persist after the loop completes, in kind of a strange way. For $X = 1 to 4 Next ConsoleWrite($X & @CRLF) ;Output = 5 Link to comment Share on other sites More sharing options...
Richard Robertson Posted May 8, 2009 Share Posted May 8, 2009 Loops create a new scope in languages I use. Link to comment Share on other sites More sharing options...
weaponx Posted May 8, 2009 Share Posted May 8, 2009 Loops create a new scope in languages I use.Examples? The For loop is an exception because it doesn't require the dependent variable to exist prior to entry. Link to comment Share on other sites More sharing options...
monoceres Posted May 8, 2009 Share Posted May 8, 2009 Nope but the variable created in a For loop will persist after the loop completes, in kind of a strange way. For $X = 1 to 4 Next ConsoleWrite($X & @CRLF) ;Output = 5 Not very strange. $X in this case is incremented until to doesn't meet the logical test anymore (in this case <=4) and it doesn't fail until $X=5. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Richard Robertson Posted May 8, 2009 Share Posted May 8, 2009 C# for sure... I think the Microsoft compiler for C++ does it, but I can't recall. Link to comment Share on other sites More sharing options...
Valik Posted May 8, 2009 Share Posted May 8, 2009 C++ and C# create a new scope every time you use { }, more or less: void Test() { // Function scope int iFunctionScope = 0; { // Nested scope int iNestedScope = 2; } // iNestedScope no longer exists } AutoIt only has function scope. Variables created inside conditional statements, loops, et cetera still go to function scope and not a new nested scope. WideBoyDixon, it's called dry-coding and not paying much attention. You get the point at any rate. Link to comment Share on other sites More sharing options...
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