Chiitus Posted March 11, 2015 Share Posted March 11, 2015 Hey guys, i'm trying to creating 7 variables in a "For" function, to not declare one by one. But i get errors, here is the code: Local $i = 0 Local $bday = _DateAdd("D", -$i, _NowCalcDate()) ; For $i = 0 To 6 Local $bNewDate[$i] = 0 Next ;Options Local $aArray[7] = [$bNewDate[6], $bNewDate[5], $bNewDate[4], $bNewDate[3], $bNewDate[2], $bNewDate[1], $bNewDate[0]] Are this code stupid or am i stupid for don't see the error hahaha Sorry i'm noob as a Autoit programmer Link to comment Share on other sites More sharing options...
Solution mpower Posted March 11, 2015 Solution Share Posted March 11, 2015 Here is an example: #include <Date.au3> #include <Array.au3> Dim $variables[7] For $i = 0 To Ubound($variables) - 1 $variables[$i] = _DateAdd("D", -$i, _NowCalcDate()) Next _ArrayDisplay($variables) ;now you can call each variable on its own via $variables[X] where X is the row. ;For example: For $i = 0 to Ubound($variables) - 1 MsgBox(0, '', 'Variable $variables[' & $i & ']='&$variables[$i]) Next Link to comment Share on other sites More sharing options...
Chiitus Posted March 11, 2015 Author Share Posted March 11, 2015 (edited) Here is an example: #include <Date.au3> #include <Array.au3> Dim $variables[7] For $i = 0 To Ubound($variables) - 1 $variables[$i] = _DateAdd("D", -$i, _NowCalcDate()) Next _ArrayDisplay($variables) ;now you can call each variable on its own via $variables[X] where X is the row. ;For example: For $i = 0 to Ubound($variables) - 1 MsgBox(0, '', 'Variable $variables[' & $i & ']='&$variables[$i]) Next Oh thanks! I will test this, really thanks, i appreciate! EDIT: This Works!!!! This "_ArrayDisplay" function is so good! Really thanks! I can't give you a like because "You have reached your quota of positive votes for the day", sorry. Edited March 11, 2015 by Chiitus 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