Jump to content

How to create arrays in a for loop


Recommended Posts

Welcome to AutoIt and the forum!

Can you please tell us why you need to dynamically create arrays?
I never had the need to create arrays this way and I'm sure it can become quite complex.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

may be you are looking for this 
 

#include <Array.au3>

Local $aArray[1]
_ArrayAdd($aArray, "one thing")
_ArrayAdd($aArray, "another thing")
_ArrayAdd($aArray, "another thing")
For $i = 1 To 20
_ArrayAdd($aArray, $i)
Next

For $i = 0 To UBound($aArray)-1
    ConsoleWrite($aArray[$i] & @CRLF)
Next

https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayAdd.htm

Link to comment
Share on other sites

Thanks. 

 

sure, i am reading multiple text files with hardware information one at a time and  saving manipulated data (simple strings) to an array. 

I want to create an overview about the number of machines that are using a specific hardware element and the number of machines that are using a similar/ the same hardware configuration while saving which machine has what by saving the ip addresses corresponding to the machines and their hardware configuration.
the data in the Textfile can look like this (file Attached)

 

I am not very experienced at all this is my second thing that i am doing ^^ 

I am very happy to find out easier,better or just alternativ ways to archiving my goal.

 

My thinking was cycling through the files with a loop and reading the hardware information in an array, $aCurrentHardwareConfig[Category like Motherboard] [Specific Part saved as the string behind :] ( this Array will then compare itself with $aOverviewHardwareConfig wich saves the added up strings from Specific Parts, a counter and the added up Ip Adresses of the machines that got true when comparing the added up string of hardware. If it gets false it wil create a new array entry with his added up hardware from $aCurrentHardwareConfig and add the ip address saved in the .txt . 


I also wanted to Save the number of machines with a spefic hardware part. Thats why i wanted to create one Array for each category so i can just save the Diffrent hardware parts in an array with a counter and add one if a new graphics card gets discovered.

That would mean i need to creat an Array for every category but the categories arent fixed. 

That was probably to much information. Its hard to gague whats important for another person... 
Thanks for the interest.

 

 


 

 

Hardwareinfo.txt

Link to comment
Share on other sites

Quote

That would mean i need to creat an Array for every category but the categories arent fixed. 

I would create a single array for this with the first column holding the category. I think this makes the handling much easier compared to handle a growing number of arrays.

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...