Jump to content

How to declare arrays if I don't know their number?


Go to solution Solved by Nine,

Recommended Posts

Posted

Classic array creation method

Local $aArray[4]
$aArray[0] = "Jasper"
$aArray[1] = "Beethoven"
$aArray[2] = "Pinky"
$aArray[3] = "Fidget"

But what if I need several arrays from a file, and I don't know how many arrays there will be?

Local $aArray1[4]
Local $aArray2[10]
Local $aArray3[6]
Local $aArray4[2]
Local $aArray...[...]

How can I declare arrays at runtime? Maybe an array list whose length I can change?
Is there another way to store such data?

  • Developers
Posted

Did you look at the Helpfile? https://www.autoitscript.com/autoit3/docs/intro/lang_variables.htm

Quote

Arrays and Maps

AutoIt has 2 types of data collection variables: Arrays and Maps.

Arrays are much faster for random access and can have multiple dimensions - a dimension size is fixed at the initially declared value (although it can be altered using ReDim).

 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)

Yes > Variable subscript badly formatted.:

And a lot of complaints here on the forum that this is a mistake in the help.

 

Edited by mike2003
  • Solution
Posted (edited)
Posted (edited)

How can I remove a specific element?

For example "UK". So that the loop now returns only two elements.

 
Quote

Removes one specified key/item pair from the Dictionary object.

 

Edited by mike2003

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
  • Recently Browsing   0 members

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