fielmann Posted March 5, 2008 Share Posted March 5, 2008 (edited) Hello autoit friends,howto create a dynamic number of loops? It should like like (e.g. for a number of 3 loops):;~~~~~~~~~~~~~~~~~~For $loop1 = 1 to 10 For $loop2 = 1 to 10 For $loop3 = 1 to 10 ; do something next nextnext;~~~~~~~~~~~~~~~~~~But how to make it DYNAMIC ?Any ideas? Carsten Edited March 5, 2008 by fielmann Link to comment Share on other sites More sharing options...
Xand3r Posted March 5, 2008 Share Posted March 5, 2008 (edited) is this what you want? $min=Random(1,10,1) $max=Random(10,100,1) For $i=$min to $max ;do stuff Next if not then try to explain better what you want.. Edited March 5, 2008 by alexmadman Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro Link to comment Share on other sites More sharing options...
martin Posted March 5, 2008 Share Posted March 5, 2008 (edited) Hello autoit friends, howto create a dynamic number of loops? It should like like (e.g. for a number of 3 loops): ;~~~~~~~~~~~~~~~~~~ For $loop1 = 1 to 10 For $loop2 = 1 to 10 For $loop3 = 1 to 10 ; do something next next next ;~~~~~~~~~~~~~~~~~~ But how to make it DYNAMIC ? Any ideas? Carsten You need some sort of recursive function. Here is a simple example Dim $a[4] = [3,4,5,2];the upper count for each loop Dim $r[4] Global $x=0 startloop($a,0) Func startloop($b,$c) Local $n If $c < UBound($b) Then For $n = 1 To $b[$c] $r[$c] = $n Startloop($b,$c + 1) Next Else Dosomething() EndIf EndFunc Func Dosomething() $x += 1 ConsoleWrite("loop vals are ") For $p = 1 To UBound($a) ConsoleWrite($r[$p - 1] & ', ') Next ConsoleWrite( "count = " & $x & @CRLF) EndFunc BTW, welcome to the forums; an interesting first question. EDIT: improved example a bit Edited March 5, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
fielmann Posted March 6, 2008 Author Share Posted March 6, 2008 You need some sort of recursive function. Here is a simple example [...] BTW, welcome to the forums; an interesting first question. EDIT: improved example a bit Hello Martin! thx 4 reply an the example with the recursive function. that was exactly what I'm seraching for thx also 4 your pleasent welcome! I work several years with autoit 2 + 3, but I never realized this forum. 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