Sign in to follow this  
Followers 0
Chiitus

Creating variables in a For function

3 posts in this topic

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  >_<

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by Chiitus

Share this post


Link to post
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
Sign in to follow this  
Followers 0